Exporting Zotoro to excel

Zotoro, a reference management software, like most of reference management tools has a compatibility problem of exporting content to a non-reference style (like excel style).

I used some python code to do this, but before getting to python you need to manually export all the collections in Zotoro to “Refer/BibIX” format; which will create a txt file containing references. Create a directory and move all files there.

This script accept the directory path as input:

#! /usr/bin/env python

import sys
import os

directory = sys.argv[1]

if len(sys.argv) < 1:
	sys.exit('Usage: ./zotoro.py directory')

if not os.path.exists(directory): 
	exit('Directory not found!.\nUsage: ./zotoro.py directory')

files = os.listdir(directory)

for theFile in files:
	with open(directory+'/'+theFile) as infile:
		for line in infile:
			txt += line

myMap = [('%0 ', ''), ('%T ', '\t'), ('%V ', '\t'), ('%N ', '\t'), ('%P ', '\t'), ('%U ', '\t'),
('%J ', '\t'), ('%A ', '\t'), ('%D ', '\t'), ('%X ', '\t'), ('%K ', '\t'), ('%B ', '\t'),
('\r\n\t', '\t'), ('\r\n\r\n','***'), ('\r\n',''), ('***','\r\n')]

for k, v in myMap:
	txt = txt.replace(k, v)

f = open(directory+'/output.xls','w')

exit("now you can open the output.xls with excel")

Well, I know there are some problems with this code such as tags that are not included and may mess up the position of the field in excel column.
Even though this code is just for demonstration of the idea, I am currently working on fully functional code to convert Zotoro (Refer/BibIX) to excel format ASAP.