Created
March 11, 2023 00:46
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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