Fix single file input, newline and header in xml
This commit is contained in:
@@ -110,10 +110,10 @@ if os.path.isdir(csvPath):
|
||||
csvArrs[i].append(row)
|
||||
|
||||
else:
|
||||
csvFileNames[0] = csvPath
|
||||
csvFileNames.append(csvPath)
|
||||
with open(csvPath, newline='') as csvfile:
|
||||
incsv = csv.reader(csvfile, delimiter=';')
|
||||
csvArrs[0] = []
|
||||
csvArrs.append([])
|
||||
for row in incsv:
|
||||
csvArrs[0].append(row)
|
||||
|
||||
@@ -185,14 +185,17 @@ print()
|
||||
# --------------------------------- Write xml -------------------------------- #
|
||||
|
||||
data = ET.Element('Leolvasasok')
|
||||
data.tail = '\r\n'
|
||||
for mérő in allXmlData:
|
||||
currSub = ET.SubElement(data, 'Leolvasas')
|
||||
currSub.tail = '\r\n'
|
||||
for adat in mérő:
|
||||
a = ET.SubElement(currSub, adat)
|
||||
a.text = mérő[adat]
|
||||
a.tail = '\r\n'
|
||||
|
||||
print(ET.dump(data))
|
||||
print()
|
||||
|
||||
tree = ET.ElementTree(data)
|
||||
tree.write(fileName)
|
||||
tree.write(fileName, encoding="utf-8", xml_declaration=True)
|
||||
|
||||
Reference in New Issue
Block a user