-
Notifications
You must be signed in to change notification settings - Fork 0
/
convertCSV2QIF.py
29 lines (23 loc) · 962 Bytes
/
convertCSV2QIF.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/python
import csv
import sys
def readCategories(catfile):
def ask_and_update_categories(naam_tegenpartij, categories):
def getCategory(categories, naam_tegenpartij):
if naam_tegenpartij in categories.keys():
category = categories[naam_tegenpartij]
else:
category, categories = aks_and_update_categories(naam_tegenpartij, categories)
return [category, categories]
def main():
if len(sys.argv) != 2:
print "usage: ./convert.py infile categoriesfile"
sys.exit(-1)
infile, catfile = sys.argv[1:2]
categories = readCategories(catfile)
reader = csv.reader(file(infile), delimiter=";")
header = reader.next()
for row in reader:
valutadatum, ref_vd_verrichting, beschrijving, bedrag_vd_verrichting, munt, datum_v_verrichting, rekening_tegenpartij, naam_tegenpartij, mededeling1, mededeling2 = row
category, categories = getCategory(naam_tegenpartij, categories)
main()