added path as first argument

This commit is contained in:
Erik Örtenberg 2025-11-24 02:04:06 +01:00
parent aef92da909
commit cda6624e7d

View File

@ -1,6 +1,13 @@
import csv
from functools import reduce
import re
import sys
if len(sys.argv) < 2:
path2file = "konto.csv"
else:
path2file = sys.argv[1]
def float2(value, default=0.0):
if value is None:
@ -14,7 +21,7 @@ print("Detta program rapporterar skillnader mellan verifikat som refererar till
lines = []
result = []
with open("konto.csv", "r") as file:
with open(path2file, "r") as file:
lines = file.readlines()
startLine = 12
@ -26,14 +33,14 @@ for i, line in enumerate(lines):
startLine = i
break
with open("konto.csv", "w") as file:
with open(path2file, "w") as file:
file.writelines(lines[startLine:-1])
with open("konto.csv", "r") as file:
with open(path2file, "r") as file:
csvreader = csv.DictReader(file, delimiter=";")
for row in csvreader:
result.append(row)
with open("konto.csv", "w") as file:
with open(path2file, "w") as file:
file.writelines(lines)
# FILE RESTORED, PARSE DATA