Ok, so I’ve played with the script above (Spreadsheet to Obsidian Project: CSV to MD Files Script (Python) · marcusolsson/obsidian-projects · Discussion #581 · GitHub), and I’m pretty close to making this work!
First, I exported .aeon into .csv, making sure to move the column ‘Label’ on the far left so it’s first. I run the script and we get outputted mds (with ‘Label’ as the file name) and info like this in the frontmatter of each file (between three dashes - - - )
---
Type: Character
Color: Grey
Siblings: Morgaine
Start Date: 11808-01-08 21:30
End Date: 11852-08-05 23:30
---
That gives us a number of properties for each exported item, like ‘Start Date’ to ‘Type’ and various relationships.
Now what I changed. For the last part of the script:
# Open the .md file for writing
with open(md_filename, 'w', encoding='utf-8') as md_file:
# Write attributes to the .md file
md_file.write('---\n')
for header in headers:
if header != headers[0] and row[header]:
md_file.write(f"{header}: {row[header]}\n")
md_file.write('---\n')
I change the line
md_file.write(f"{header}: {row[header]}\n")
to
md_file.write(f"{header}: ‘[[{row[header]}]]’\n")
Adding ‘[[ ]]’ to the outside of row[header] turns the information into a usable wiki-link in Obsidian’s properties.
In the Source Mode for the md files it now looks like:
---
Type: '[[Character]]'
Color: '[[Grey]]'
Siblings: '[[Morgaine]]'
Start Date: '[[11808-01-08 21:30]]'
End Date: '[[11852-08-05 23:30]]'
---
and in the File Properties there is now a hyperlink!
The problem is for properties that have several different items.
For something like my Extended Family section, it smushes all of the names together, and the hyperlink is… that long one-word-smush.
---
Extended Family: '[[Sioris,Piers,Eglė,Rhianu,Síofra,Ophion,Elwin,Gwythyr]]'
---
Meaning that I have 1 hyperlink that’s just:
Sioris,Piers,Eglė,Rhianu,Síofra,Ophion,Elwin,Gwythyr
BUT, if the frontmatter is changed up, and each item is on its own line, with the hyperlink brackets and the apostrophe (like this):
---
Extended Family:
- '[[Sioris]]'
- '[[Piers]]'
- '[[Eglė]]'
- '[[Rhianu]]'
- '[[Síofra]]'
- '[[Ophion]]'
- '[[Elwin]]'
- '[[Gwythyr]]'
---
it shows up in Properties as separate hyperlinked files!
Now I just need to be able to make the script understand that certain columns don’t need a hyperlink at all (like summary), and others need just one hyperlink, and others are several different things in the column and need to be exported as a list.
I assume I have to change up this part
if header != headers[0] and row[header]:
md_file.write(f"{header}: {row[header]}\n")
To be about specific columns instead of all of them, and that might need some extra changes.