Turning a CSV file into separate Markdown entries with metadata

Apologies if this is covered by another post, but my initial research on importing CSV files didn’t make anything super obvious to me.

I have a CSV file with over 2000 lines, which I would like to import as separate markdown notes into a new Database or Group, with one of the fields used as a markdown text, another used to create the file name, another with comma-separated tags which I would like to be converted into DEVONthink tags. There might be a couple of other fields to convert into other metadata entries in DT. Does anyone have a starter script or suggested workflow to help me get this done?

Thanks in advance.

Just FWIW, I imagine the CSV → markdown conversion would likely be better handled outside DT without scripting.


JJW

1 Like

It would be easier to help you if you’d show summer mines of three CSV and how you want them to show up in MD files.

Welcome @bdtrigg

Is this a .csv file you created? In what application?

And some example lines and an example of the output would be helpul.

Here is a sample CSV.

‘content’ would be the content of the file, ‘title’ could become the title of the markdown file, although I may look at trying to wrangle the ‘reference_start’ and ‘reference_end’ entries to create the title, but that’s my problem… the main thing would be also to make sure any comma-separated values in the ‘tag’ column become DT tags. Maintaining the date_created field as a DT Date Created metadata would be useful too.

Is this from Excel or Numbers or exported from Logos/Accordance/…?

Why? Apart from the fact that the product you linked to is not free – the sample they show is just converting CSV data into an MD table (something a one-liner could do with awk or sed, for free, btw).

I guess if the OP wanted to have a table, they could import their CSV into Excel. And they said that they have “over 2000 lines, which I would like to import as separate markdown notes”. That might mean “one line – one note”.

All assumptions, of course. If it were me, I’d script it. @BLUEFROG might come up with something that does not require coding.

Exported from OliveTree using their online tool. No other way that I’ve found to export notes from there

Hold the Option key and choose Help > Report bug to start a support ticket. Thanks!

1 Like

I use a custom applescript to process .csv files; generating separate Devonthink notes
My use-case is .csv transaction files downloaded from the bank
The script “wrangles” the .csv data; formats the note title, content, and assigns tags

Click for sample script
tell application id "DNtp"
	
	set theFilingGroup to get record with uuid "878AADEA-A15F-4DBD-B9B9-BF59099F5554"
	set selctedFiles to selected records
	repeat with theBankcsvFile in selctedFiles -------------------------------Process each .csv file; extract the contents
		set theBankcsvName to name of the theBankcsvFile
		set theBankcsvPath to path of theBankcsvFile as string
		set theBankcsvText to paragraphs of (read theBankcsvPath as «class utf8»)
		my process_Rows(theBankcsvText)
		set theNote to move record theBankcsvFile to theFilingGroup
		set name of theNote to "StatementCSV [" & theBankcsvName & "] " & theDate & " zcType-StatementCSV " & theVendor
		set tags of theNote to tags of theNote & {"zcType-StatementCSV", theVendor}
	end repeat
end tell

on process_Rows(theBankcsvText)
	repeat with theBankcsvRow in theBankcsvText --------------------------- Process each row 
			set theNoteTitle to my Process_Columns(theBankcsvRow) -------------- Parse the row content by columns
			set theNoteTags to Process_Tags(theNoteTitle)
			set theoffset to offset of "]" in theNoteTitle
			set theDate to date (text (theoffset + 7) thru (theoffset + 11) of theNoteTitle & "-" & text (theoffset + 2) thru (theoffset + 5) of theNoteTitle)
			tell application id "DNtp" ----------------------------------------------- Create Note
				set theNewRecord to create record with {name:theNoteTitle, type:txt, content:theBankcsvRow, tags:theNoteTags} in theFilingGroup
				set creation date of theNewRecord to theDate
			end tell
	end repeat
end process_Rows

on Process_Columns(theBankcsvRow) ---------------------------------- Process Clolumns
	set theBankcsvColumns to ParceCSV(theBankcsvRow, ",")
	...
	set noteTitle to "Banking [" & detailContent & "] " & dateContent & " $" & amountContent
		return noteTitle
	end Process_Columns
2 Likes

Because creating an awk or sed or a custom AppleScript is for some folks also not “free” or as unambiguously obvious or as immediately error-free as it may be for you to do.


JJW