From f114faf2d282abd2244cf5c6dfb5bfa08b3b9412 Mon Sep 17 00:00:00 2001 From: MReenen Date: Sat, 31 Dec 2022 14:09:20 +0100 Subject: [PATCH] make inputfile an argument --- convert.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/convert.py b/convert.py index 2549bcb..f4f4d7c 100644 --- a/convert.py +++ b/convert.py @@ -1,5 +1,6 @@ import fs import csv +import sys def parseRow(row, header): d = {} @@ -109,11 +110,11 @@ def convert(row): return row -def main(): +def main(inputFile): global Keys rows = [] csv.register_dialect('thing', delimiter=';', quoting=csv.QUOTE_ALL) - with open('coolhaven_2022.csv', mode ='r') as file: + with open(inputFile, mode ='r') as file: imp = csv.reader(file, 'thing') headers = False @@ -202,7 +203,13 @@ def main(): # yield parseRow(row, headers) if __name__ == '__main__': - main() + + print(sys.argv) + + if (len(sys.argv) == 2): + main(sys.argv[1]) + else: + print("please use one orgument for the path to the imputfile") # "Datum";"Naam / Omschrijving";"Rekening";"Tegenrekening";"Code";"Af Bij";"Bedrag (EUR)";"Mutatiesoort";"Mededelingen";"Saldo na mutatie";"Tag"