CSV-backed data table idea

Just had an idea I had to get out of my head while looking at my old Notion exports: A plugin to render tables based on CSV data.

The general idea is simple, use normal Obsidian embedding syntax for a CSV file (![[mydata.csv]]) and in preview view, render the data in a HTML table. If at all possible, it would be good to be able to pass the CSV data through the Markdown parser as well, so cells can be formatted, contain internal links or even other embedded content!

This would be just the beginning, also. It would be great to extend that with an almost spreadsheet-like table editor to edit the CSV files directly in a more UX-friendly way. Perhaps even basic spreadsheet-like formulas and cell references, the results of which can be calculated on render.

44 Likes

I’m already hearing this as one of the pain points for potential Notion to Obsidian converts. I’m glad this has been posted. In addition to more advance spreadsheet capability, I could see a table plugin to satisfy the Notion crowd (call it an Obsidian database for them) that allows you to sort columns or manually rearrange in real-time. Could be a mode where it just collects all #Tags and [[Links Within]] or come up with a way to separate content links & tags from organizating links & tags for each page. Maybe designate a Section for the plugin to recognize as metadata similar to the to metadata area in Notion. Or the user chooses a rule that all organizing tags have to be above the first heading. There are endless sollutions. But hopefully a graceful one is found to reliably work with the potentially ‘messy’ nature of markdown.

Some Project Plans

Obsidian Notes Tags Categories
[[Big Project]] #process #delegate [[Rent Job]] [[Client 4]]
[[Little Project]] #done #document [[Client 3]] [[Outsource 2]]
[[Just Right Project]] #assign #review #explore [[Invoice 2]]
[[Endless Project]] #done [[Client 1]] [[Location 3]]
12 Likes

Yes! Good idea @death.au . +1 :smiley:

I was just thinking of writing a script to convert CSV files to markdown tables, but a plugin would be even better.

And @goodsignal’s idea with the metadata would be awesome!


I would love to see this added as a plug-in but I’m still toying with the idea of building something. Maybe the CSV file could be rendered in an iframe. I’d rather not rely on another service, but something like this might work:

4 Likes

Really hope this come reality. For me it’s the most important missing feature.

3 Likes

+1 on this. I really hate the idea of creating markdown tables for any csv i’d like to import when the CSV is already super accessible

4 Likes

Excellent idea. It reminds me of Texthaven, a Markdown editor which can also create and edit CSV files. See the details here: Texthaven CSV features

6 Likes

Just want to report that now there is a decent Table Manager as a Third-Party Plugin called

I often use these two tools for md table conversion

However, it would be so much more powerful if @death.au suggestion was implemented. I keep resisting converting to md tables because it feels like such a death sentence for dynamic data. The maintenance cost gets so high for anything but final presentations.

It would be nice to maintain spreadsheet data using real spreadsheet apps and see the results automatically rendered in Obsidian as a md table based on an embedded CSV.

Even better with a few basic modification options for any embed, like: Center-align text; Bold first row; Bold last row; Format numbers, …

7 Likes

I tried talking the idea up on Discord but it didn’t get play. I felt it was a compelling argument so I’m copying it here.

I’m curious Licat, is embedding .CSV to render as a MD table something you’d consider building in?

  • It seems worthy of being a core feature when you consider how accessible, universal, and user friendly they (CSVs) are.
  • CSV is a powerful file format. Thousands of refined tools already exist to manipulate them.
  • The core principles of CSV are nicely aligned with markdown.
  • And when you consider future proofing, CSV integration is more resilient than PDF integration.
  • Unlike PDF, it can at be integrated directly as a table and exported as part of the .md document, should we ever need.
  • Considering Obsidian’s existing featureset, it seems like a natural marriage.

One additional plug for being a core feature is that it seems like it could be a powerful tool for other 3rd Party Plug-ins to have API access to. Seems like it could be an enabler for more advanced tools while maintaining relative simplicity in implementation and maintenance from the Obsidian side.

12 Likes

This would also support orthogonality with other tools, i.e. users can use the entire ecosystem of text-manipulation and csv-manipulation tools to work with / update the csv files separately from Obsidian as well, without requiring the Obsidian devs to build in a lot of unnecessary API hooks. (of course allowing it to be updated from within Obsidian would be useful, I just mean it shouldn’t be expected to only be updated through Obsidian)

I watched a video last night where a user was using a Python script to update a table in a note each day with running statistics. This would be easier to manage with the Python script updating the csv and not having to think about the display format, and Obsidian simply rendering the csv as a simple table when called.

5 Likes

Seriously! Lots of bang for the buck in this feature.

I’m crossing fingers for the possibility of my CAD BIM tools seamlessly updating tables in the background for the PDF reports I build and generate with Obsidian, without any additional scripting.

2 Likes

I would love to cee CSV become a second type of note within Obsidian. I use Excel a lot for keeping track of data and ideas and collections. None of this required formulas, just big tables and a bit of formatting. Being able to move all of that into Obsidian would be incredible.

5 Likes

Another reason why this could become phenomenally powerful is it can enable the creation of an entire ecosystem of capabilities around Obsidian as the platform.

Obsidian honestly has the potential to become the 21st century version of emacs when it comes to note taking (not programming) and just look at how insanely powerful emacs is.

Like emacs, Obsidian:

  • works with plain text files
  • has a simple plugin architecture
  • can be easily extended using a relatively easy to learn language

And by being written in JS it can leverage thousands of useful packages and libraries for a nearly endless variety of capabilities and workflows.

Obsidian can become a platform not just a single application if it integrates a simple data capability by including CSVs as a supported data structure.

Obsidian doesn’t need to provide a CSV editor or fancy query access (though queries could come later) but simply supporting the display of CSVs for now could unlock significant capability because we could use any of the thousands of other tools to update/manipulate the CSV.

Personally I’m already starting to use Obsidian as a pseudo dashboard in some ways for my daily tasks/etc and can only imagine the capabilities this type of feature could open up.

3 Likes

Just to update everyone here, I have done some work towards building a CSV viewer/editor plugin. Like @davecan mentioned above:

Which means I have access to a bunch of existing javascript datagrid implementations that already exist with features like filtering and sorting.

I’ve hit some hurdles with the datagrid I was using not working properly inside Obsidian, but I’m hopeful I can either fix these or otherwise drop in a different library with similar capabilities.

9 Likes

Plug: Along with that please see

1 Like

Awesome, thanks @death.au! I’m definitely interested in the evolution of this capability.

4 Likes

Another example use case: Habit tracking and summaries by sections from daily entries on Obsidian (code) : ObsidianMD

Script author is manually building markdown tables.

There is a CLI tool called csvquery which supports a full range of operations, but does introduce external dependencies.

I wonder how difficult it would be to develop a simple lightweight projection-only DSL for use in ```query``` blocks.

Perhaps similar to LINQ syntax:

```csv
from(path...) 
where(
    colA in(
        date(yesterday), date(today)
    )
)
select(colA, colC:newname) 
```

Would need:

  • tokenizer that can recognize parens
  • parser to convert the tokens into semantics
  • execution engine converting the projection into Node.js calls against the CSV
2 Likes

There is a very promising plugin which aims to implement CSV support, too.

1 Like

By the way – I wrote a plugin for scratching a similar itch a while back: GitHub - coddingtonbear/obsidian-csv-table: Have a CSV file you want to render some or all of the data from? This plugin allows you to display that data in your obsidian preview.

6 Likes

This is so great! Thanks @coddingtonbear !

I couldn’t get it to work at first so I’ll offer a couple use notes for other users that can’t get it to work.

  1. The source file name has to be in double quotes regardless of whether or not there are spaces in the file name, like source: "my_csv_file.csv"
    The README demonstrates no quotes, source: my_csv_file.csv
    but in practice, that doesn’t work.
  2. The plugin does not read from the same directory as the current .md that is calling the csv. This plugin reads from your vault’s root directory. That surprised me. I would have expected the standard for relative file referencing, using ../ to move up a directory, and ./ to point to the vault (root) directory.
  3. Also, if you want to keep your CSV in the same directory as the .md file that’s calling it, then you must build out the address with forward slashes
    source: "/Documentation/my_csv_file.csv"
    not the backwards slashes that are default for a windows system.
    source: "\Documentation\my_csv_file.csv"

I’m using Windows 10

The interactivity @death.au has integrated is amazing. If you ever fiddle with this code again, please give us a way to embed the csv table in our .md files when in preview mode.