Skip to content

Instantly share code, notes, and snippets.

@kvgc
Created March 11, 2023 00:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kvgc/12eec2189ac526a4462b4515ed065dd2 to your computer and use it in GitHub Desktop.
Save kvgc/12eec2189ac526a4462b4515ed065dd2 to your computer and use it in GitHub Desktop.
Convert the zotero's exported csv to TW5 compatible json file. Run the following code and drag-and-drop the json files to Tiddlywiki to import them as separate tiddlers.
import pandas as pd
import json
zoteroExportFile = "zoteroExport.csv" ## Contains the csv exported from zotero
folder = "zoteroExport/"
t = pd.read_csv(zoteroExportFile)
for i in range(len(t["Title"])):
with open(folder+t["Key"][i] +".json", "w") as outfile:
if(type(t["Manual Tags"][i])==str):
## tags given by the authors or journal
getTags = ["".join(i.split(" ")) for i in t['Manual Tags'][i].split(';')]
else:
getTags = []
json_object = json.dumps({
'text' : "{{!!annotations}}", #Tw5
'tags' : 'zotero-export ' + ' '.join(getTags), #Tw5
'modified' : '' , #Tw5
'created' : '' , #Tw5
'title' : t["Title"][i], #Tw5
'author' : t['Author'][i],
'zoteroKey' : t['Key'][i],
'annotations' : t['Notes'][i] if type(t['Notes'][i])==str else ''
}, indent=4)
outfile.write(json_object )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment