From 094dfd9b4cb6d628f79370918ad4ef2019e2f573 Mon Sep 17 00:00:00 2001 From: MReenen Date: Tue, 7 Feb 2023 16:23:36 +0100 Subject: [PATCH] add argument to home converter --- convert.home.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) mode change 100644 => 100755 convert.home.py diff --git a/convert.home.py b/convert.home.py old mode 100644 new mode 100755 index 512ddb4..7220e7e --- a/convert.home.py +++ b/convert.home.py @@ -1,3 +1,6 @@ +#!/usr/bin/python3 + +import sys import fs import csv @@ -19,9 +22,9 @@ def deparseRow(row): Keys = [] def convert(row): global Keys - + print(row) - + #row['Datum'] = f'{row["Datum"][0:4]}-{row["Datum"][4:6]}-{row["Datum"][6:8]}' row['Datum'] = row['Datum'].split('-') row['Datum'] = f'{row["Datum"][2]}-{row["Datum"][1]}-{row["Datum"][0]}' @@ -106,12 +109,12 @@ def convert(row): return row -def main(): +def main(inputFile): global Keys rows = [] csv.register_dialect('2004', delimiter=';', quoting=csv.QUOTE_ALL) csv.register_dialect('new', delimiter=',', quoting=csv.QUOTE_NONE) - with open('input.csv', mode ='r') as file: + with open(inputFile, mode ='r') as file: imp = csv.reader(file, 'new') headers = False @@ -200,7 +203,15 @@ 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") +# if __name__ == '__main__': +# main() # "Datum";"Naam / Omschrijving";"Rekening";"Tegenrekening";"Code";"Af Bij";"Bedrag (EUR)";"Mutatiesoort";"Mededelingen";"Saldo na mutatie";"Tag"