KNIME - Convert Markdown to CSV (Patreon)
Downloads
Missing 14 full-res photos, 1 file, as this post has not yet been imported.
Content
Most of the time, I'm trying to get data into Obsidian. Today a fellow Obsidian user asked for help getting his data out of Obsidian. He had manually put the data in but was not happy with the layout; he wanted to convert the individual notes to *.csv so he could use tit with the JSON/CSV Importer plugin and re-make his notes with a better look and feel.
Great use case... hold my beer :)
The great news was the data had a structure to it. Headings were used in the same way across multiple notes. This is important to making this work.
What we needed to do was turn this note (and all the other spell notes!) into a simple table with a structure like this:
But with 1x line of data for each note.
This was a job for KNIME which I've made a video on previously.
There will be at least 3 people reach out and ask why use Knime and not some raw script method. A large chunk of our community are not scripters. Knime is open source, free and the visual coding method allows people to follow the process. This means I can build a work-flow and share it and someone with lower technical ability can run that workflow relatively easily.
The workflow looks like a bunch of spaghetti. But if you break it down it's rather simple.
1. It connects to a folder and brings in all the notes.
2. It filters the rows using the ### Headings within the files to break each note into sections.
3. It copies the content between each of the listed headings and saves that into a column that matches the name we want in the output.
4. It saves the output to a CSV file.
Yes there's more to it than that. Lots of little problems with each step that had to be solved. If you would like to inspect this further you can right click the nodes and review the Configuration.
Can I Use It?
Yes you can.
KNIME Basics
- Right click a node > Configure > set node settings here
- Right click a node > Execute > the workflow will execute up to this node.
- Right click a node > At the bottom of the menu are the options for any data outputs. Click them to open a window that shows the data that has been generated up to the selected node. This is a great way to step through a workflow and see what's happening with your data.
Workflow Instructions
1. Download and install KNIME.
2. Download and open the attached workflow.
3. Within the workflow, right click on the List Files/Folder node and select Configure.
4. Update the folder path.
5. The folder you pick is where you should save all the files you want to feed into the workflow.
6. Within the workflow, right click on the CSV Writer node and select Configure.
7. Update the filename and select where you would like it saved.
8. Right click on the CSV Writer node and select Execute.
9. Once the node turns green, the batch is complete and you can go find your new *.csv file.
Can I Modify This For My Needs?
Yes, that absolutely should be possible and relatively easy to do. I have highlighted a chunk of nodes in a yellow box. This is to give you an idea of a section of nodes that is designed to isolate a specific piece of information.
To understand how it works. Right click on the Nominal Range Row Filter and select Configure.
Here you can see the Starting Term and the Ending Term have been configured.
If you review the original note, you can see that the Starting Term and Ending Term are being used to isolate the data between these strings
Hint: String is a fancy data term for data that is made up of characters or words.
So basically, the node captures the data we need. Then we use the Value Filter Definition node to filter out all the rows that contain a heading. So you should configure the Value Filter Definition node also.
Add any of the headings into the Exclude column and click OK.
Next you need to update the Column Rename node. Right click Configure and change the name to match the name of the column that you are making.
That's the basic configuration. Keep in mind that you would need to adjust each row of nodes to align it with the structure of your own note. You might need to remove lines or add lines to match the format you are working with. You can highlight a row of nodes and simply copy and paste to make new ones and then repeat the configuration from above.
The last two rows in the work-flow are much more complex.
The second to last one is dealing with a paragraph of information. There's a bit more work involved in converting the data into a readable paragraph. If you need to add additional groups of nodes to handle a paragraph of information, copy this section.
The last row is special because it's the last row. There isn't a # Heading I can use to capture the data for the last section. So this get's a bit more complex and use's a few formulas and nodes to calculate the number of rows at the end of the note and then filters using the row numbers instead. This last section is also designed to handle a paragraph.
The final output should be a single table that can now be used in many fantastic ways such as the JSON/CSV Importer.
Hopefully this helps. It's most certainly a more advanced topic, but step through it one node at a time and hopefully it should be easy enough to understand.
Files
Previews only