Show HN: Py-obsidianmd, a Python library for Obsidian users

Hello Hacker News,

This message is relevant to those of you who use [Obsidian](https://obsidian.md/) for personal knowledge management.

py-obsidianmd is a python library that enables you to change your notes’ metadata in batch. You can also easily move your metadata between the frontmatter and inline notation (dataview style).

Checkout:

- the presentation video: https://www.youtube.com/watch?v=gRPBAKiu37Y

- github repository: https://github.com/selimrbd/py-obsidianmd

- example usage: https://selimrbd.github.io/py-obsidianmd/examples/

It has saved me a lot of time, and made me free to experiment with how I handle my knowledge base’s metadata. I hope it can also be useful to others in the community !

Let me know if you have any feedback.

Cheers,

10 points | by srbd 511 days ago

2 comments

  • CrypticShift 510 days ago
    Suppose Obsidian is a Table/DB. Every Page is a row. The metadata are its attributes.

    Sometimes, I wish I could export that DB as CSV, apply some data processing (API enrichment, transformations…) on it, then merge it back into Obsidian. Or I have a Table/DB already and I wish to convert/merge it into Obsidian Pages.

    Dataview and all the visual DB/tables plugins are either read only or do not allow for advanced data manipulation.

    Your library seems like it allows me to do just that, without intermediary formats ! Thanks!

    • srbd 510 days ago
      Hey @CrypticShift, indeed the library was designed for that type of data manipulation, which I wasn't able to do using other plugins.

      The idea was to create an intuitive bridge with python, so any type of advanced operations could be performed on your vault.

      It is still in it's early stages, so do backup your vault before using it. And feel free to share your feedback if/when you use it !

      Cheers

      • CrypticShift 510 days ago
        Genial !

        I suggest you expand and better showcase the third usage (add and remove metadata) to demonstrate how powerful this Obsidian->python->Obsidian cycle is.

        The way you formulate it makes a big difference. It is a subtle power and people need to visualize it better:

        - imagine you can export your metadata to excel/DB, apply all sort of data processing, and merge them again.

        - Have you ever wished to batch edit that read-only Dataview result or that db-folder Table?

        - What if you could use your DB/excel table dynamically in obsidian, so that rows could bidirectionally be linked to pages? (This is an advanced one, but still indirectly possible)

        You can also show how this can efficiently replace a lot of plugins (importing data from API/scraping, Data maintenance...) and a lot more, with simple and personalized python scripts.

        Bon courage !

        • srbd 509 days ago
          Lots of great application ideas, thanks for sharing. I'll think about it when expanding the tutorials.

          Same as you, I think it would be nice to have editable dataview tables; but I'm not sure this library is the answer to that. That type of feature should be directly implemented in dataview. I believe the DB-folder plugin solves this problem: https://www.youtube.com/watch?v=ibarYqG4W5I

          But I haven't tested it yet. The video presentation seems very instructive: https://www.youtube.com/watch?v=ibarYqG4W5I

          • CrypticShift 509 days ago
            > editable dataview tables; but I'm not sure this library is the answer to that

            No, I used to word "batch edit". DB-folder tables are indeed "editable" but you can't "batch edit" them. Your library allows this further step. that was my point : to show how your solution augment what dataview and DB-folder already offers (augment, not replace)

            It seems some people are using https://python-frontmatter.readthedocs.io/en/latest/index.ht... for raw batch editing. (seen here https://forum.obsidian.md/t/bulk-changes-of-markdown-files/1...)

            > when expanding the tutorials.

            IMO, You can also put python scripts in github for some precise use cases (data maintenance...), to showcase the possibilities.

            • srbd 509 days ago
              > IMO, You can also put scripts in github for more precise use cases (data maintenance...), to showcase the possibilities.

              That's how I use the library for my personal vault. Its a nice idea to share them as recipe scripts :thumbsup: I'll dig into that.

              > It seems some people are using https://python-frontmatter.readthedocs.io/en/latest/index.ht... for raw batch editing

              I use that library too, in fact it is the only dependency of py-obsidianmd. It's only used to load the frontmatter though.

              > that was my point : to show how your solution augment what dataview and DB-folder already offers (augment, not replace)

              That could be a standalone video, indeed. Show a workflow with dataview, and going further with python scripting and py-obsidianmd.

              Some plugins are being developed to run python scripts directly within obsidian (https://github.com/mProjectsCode/obsidian-script-runner-plug...),, so one can imagine running his maintenance recipes etc. without leaving the vault. Many possibilities !

  • kseistrup 510 days ago