Hello I like to import transactions into Gnu-Cash. By default my bank export is not suitable for Gnu-cash. To make it suitable I need to run it through a Python script. I am using this script below that I found on the internet. I assume that I can use this script because it was publicly available. I was not able to approach the author of the script.
While running the script it give the error
So I replaced all the tabs with spaces, but that gave a error that said that I had to use spaces.
I am not a programmer; my goals is to use this script to import data into Gnu Cash. I hope someone can help me to run this script, so I can start using Gnu-cash.
While running the script it give the error
TabError: inconsistent use of tabs and spaces in indentation
So I replaced all the tabs with spaces, but that gave a error that said that I had to use spaces.
I am not a programmer; my goals is to use this script to import data into Gnu Cash. I hope someone can help me to run this script, so I can start using Gnu-cash.
################################### # Name script: knab.py # # Parameter : Input file # # Author : Bastiaan Krijgsman # # Version : 0.1 # # Date : 03-05-2017 # ################################### from datetime import datetime import sys, csv, os class Bank: ifname = "" ofname = "" def __init__(self,ifile): self.ifname = ifile self.ofname = str(os.path.splitext(ifile)[0]) + "_" + str(datetime.now().year) + ".csv" def gencsvk(self): ifile = open(self.ifname,"rb") reader = csv.reader(ifile,delimiter=';') ofile = open(self.ofname,"wb") writer = csv.writer(ofile,delimiter=',',quotechar='"',quoting=csv.QUOTE_ALL) writer.writerow(["Rekening","Datum","Omschrijving","Toelichting","Opname","Storting"]) ## "Rekeningnummer","Transactiedatum","Valutacode","CreditDebet","Bedrag","Tegenrekeningnummer","Tegenrekeninghouder","Valutadatum; ## Betaalwijze;Omschrijving;Type betaling;Machtigingsnummer;Incassant ID;Adres; reader.next() reader.next() for row in reader: rekening = row[0] datum = row[1] #omschrijving = row[10] + " " + row[11] + " " + row[12] + " " + row[13] + \ # " " + row[14] + " " + row[15] + " " + row[16] + " " + row[17] + \ # " " + row[18] omschrijving = row[9] opname = 0 storting = 0 toelichting = row[5] + " " + row[6] + " " + row[8] + " " + row[13] if row[3] == "D": opname = row[4] if row[3] == "C": storting = row[4] nrow = rekening,datum,omschrijving,toelichting,opname,storting print row[4]+ " " + row[6] writer.writerow(nrow) bank = Bank(sys.argv[1]) bank.gencsvk() if len(sys.argv) < 2: print "No input file name given!" exit()Import.csv
KNAB EXPORT;;;;;;;;;;;;;;;; Rekeningnummer;Transactiedatum;Valutacode;CreditDebet;Bedrag;Tegenrekeningnummer;Tegenrekeninghouder;Valutadatum;Betaalwijze;Omschrijving;Type betaling;Machtigingsnummer;Incassant ID;Adres;Referentie;Boekdatum; "NL00KNAB0000000000";"06-05-2021";"EUR";"D";"115,89";"NL47RABSDFE64";"AF74 B.V.";"06-05-2021";"iDEAL";"Siet et al AF74 B.V.";"";"";"";"";"C1E0634ZJ";"06-05-2021"; "NL00KNAB0000000000";"06-05-2021";"EUR";"C";"150";"5775SDF39";"Kees de Leeuw";"06-05-2021";"Ontvangen betaling";"";"";"";"";"";"C1E06423VPZK";"06-05-2021"; "NL00KNAB0000000000";"03-05-2021";"EUR";"D";"1,85";"BE85739SDF55506";"Alipay";"03-05-2021";"iDEAL";"Hk E-Commerce";"";"";"";"";"C1E023405B";"03-05-2021"; "NL00KNAB0000000000";"20-04-2021";"EUR";"D";"3,39";"BE85739SD55506";"FS Services S.A.";"21-04-2021";"iDEAL";"Aly EUROPE LTD S.A";"";"";"";"";"C1D20werXHI";"20-04-2021";