# %% import xmlgat_to_EVT_parser as evtPar import os import xml.etree.ElementTree as ET basedir = '../../Data/' baseindir = basedir + 'DallOVI/datiniXML/xmlgat/' baseoutdir = basedir + 'DallOVI/datiniXML/xmlevt/lettere/' # %% for file in os.listdir(baseindir): try: local_filecode = file.replace('xmlgat.', '').replace('.xml', '') local_string = evtPar.newProcessFile(local_filecode) new_LocalString = evtPar.letterTemplateString.replace('', local_string) with open(baseoutdir + local_filecode + '.xml', 'w') as f1: f1.write(new_LocalString) except ET.ParseError: print("ParseError - " + file) except KeyError: print("KeyError - " + file) except IndexError: print("IndexError - " + file) print('DONE!') # %% # NOTA TEMPORANEA: allo stato attuale (16/02/2022), la grande maggioranza dei files vengono esportati con successo. # Avendo dato un'occhiata a campione, gli output sembrano buoni -- dovrebbero essere 'mangiabili' da EVT. # Ci sono perĂ² un certo numero di errori nel processare i files, la maggior parte errori di parsing di ElementTree probabilmente dovuti a stranezze nei file di input, ma alcuni paiono essere bug # --- # DA INVESTIGARE! # ParseError - xmlgat.j34.xml # KeyError - xmlgat.x03.xml # ParseError - xmlgat.j92.xml # ParseError - xmlgat.j37.xml # IndexError - xmlgat.k43.xml # ParseError - xmlgat.j95.xml # ParseError - xmlgat.k01.xml # ParseError - xmlgat.k00.xml # ParseError - xmlgat.j82.xml # ParseError - xmlgat.j62.xml # ParseError - xmlgat.j85.xml # ParseError - xmlgat.28d.xml # ParseError - xmlgat.c13.xml # ParseError - xmlgat.j88.xml # ParseError - xmlgat.j98.xml # ParseError - xmlgat.j33.xml # ParseError - xmlgat.j74.xml # IndexError - xmlgat.c33.xml # ParseError - xmlgat.j99.xml