mirror of
https://github.com/Noettore/fattureCCSR.git
synced 2025-10-15 11:46:39 +02:00
fattureCCSR: added filepicker and filedialog for input and output files. Started working on exceptions handling.
Signed-off-by: Ettore Dreucci <ettore.dreucci@gmail.com>
This commit is contained in:
19
converter.py
19
converter.py
@@ -1,10 +1,13 @@
|
||||
"""This script ask for an input file and an output file and generates the TRAF2000 records from a .csv or .xml"""
|
||||
"""ask for an input file and an output file and generates the TRAF2000 records from a .csv or .xml"""
|
||||
|
||||
import os
|
||||
import datetime
|
||||
import csv
|
||||
import xml.etree.ElementTree
|
||||
import unidecode
|
||||
|
||||
import exc
|
||||
|
||||
def import_csv(csv_file_path):
|
||||
"""Return a dict containing the invoices info"""
|
||||
fatture = dict()
|
||||
@@ -89,8 +92,18 @@ def import_xml(xml_file_path):
|
||||
return fatture
|
||||
|
||||
|
||||
def convert(fatture, out_file_path):
|
||||
def convert(input_file_path, out_file_path):
|
||||
"""Output to a file the TRAF2000 records"""
|
||||
input_file_ext = os.path.splitext(input_file_path)[1]
|
||||
if input_file_ext == ".csv":
|
||||
fatture = import_csv(input_file_path)
|
||||
|
||||
elif input_file_ext == ".xml":
|
||||
fatture = import_xml(input_file_path)
|
||||
|
||||
else:
|
||||
raise exc.WrongFileExtension("Expected .csv or .xml but received " + input_file_ext)
|
||||
|
||||
with open(out_file_path, "w") as traf2000_file:
|
||||
print("Note di credito:\n")
|
||||
|
||||
@@ -263,4 +276,4 @@ def convert(fatture, out_file_path):
|
||||
|
||||
linea = ''.join(linea) + '\n'
|
||||
|
||||
traf2000_file.write(linea)
|
||||
traf2000_file.write(linea)
|
||||
|
Reference in New Issue
Block a user