Compare commits
2 Commits
4a6d34da4d
...
141414e2b4
| Author | SHA1 | Date | |
|---|---|---|---|
| 141414e2b4 | |||
| 0209741dcf |
@@ -100,20 +100,24 @@ csvFileNames = []
|
|||||||
if os.path.isdir(csvPath):
|
if os.path.isdir(csvPath):
|
||||||
folder = csvPath
|
folder = csvPath
|
||||||
print(f'Fájlok a mappában: {os.listdir(csvPath)}')
|
print(f'Fájlok a mappában: {os.listdir(csvPath)}')
|
||||||
for i, file in enumerate(os.listdir(csvPath)):
|
files = os.listdir(csvPath)
|
||||||
|
for file in os.listdir(csvPath):
|
||||||
|
if not os.path.splitext(file)[1] == '.csv':
|
||||||
|
files.remove(file)
|
||||||
|
print(f'Csv fájlok a mappában: {files}')
|
||||||
|
for i, file in enumerate(files):
|
||||||
csvFileNames.append(file)
|
csvFileNames.append(file)
|
||||||
with open(os.path.join(csvPath, file), newline='') as csvfile:
|
with open(os.path.join(csvPath, file), newline='') as csvfile:
|
||||||
incsv = csv.reader(csvfile, delimiter=';')
|
incsv = csv.reader(csvfile, delimiter=';')
|
||||||
csvArrs.append([])
|
csvArrs.append([])
|
||||||
|
|
||||||
for row in incsv:
|
for row in incsv:
|
||||||
csvArrs[i].append(row)
|
csvArrs[i].append(row)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
csvFileNames[0] = csvPath
|
csvFileNames.append(csvPath)
|
||||||
with open(csvPath, newline='') as csvfile:
|
with open(csvPath, newline='') as csvfile:
|
||||||
incsv = csv.reader(csvfile, delimiter=';')
|
incsv = csv.reader(csvfile, delimiter=';')
|
||||||
csvArrs[0] = []
|
csvArrs.append([])
|
||||||
for row in incsv:
|
for row in incsv:
|
||||||
csvArrs[0].append(row)
|
csvArrs[0].append(row)
|
||||||
|
|
||||||
@@ -185,14 +189,17 @@ print()
|
|||||||
# --------------------------------- Write xml -------------------------------- #
|
# --------------------------------- Write xml -------------------------------- #
|
||||||
|
|
||||||
data = ET.Element('Leolvasasok')
|
data = ET.Element('Leolvasasok')
|
||||||
|
data.tail = '\r\n'
|
||||||
for mérő in allXmlData:
|
for mérő in allXmlData:
|
||||||
currSub = ET.SubElement(data, 'Leolvasas')
|
currSub = ET.SubElement(data, 'Leolvasas')
|
||||||
|
currSub.tail = '\r\n'
|
||||||
for adat in mérő:
|
for adat in mérő:
|
||||||
a = ET.SubElement(currSub, adat)
|
a = ET.SubElement(currSub, adat)
|
||||||
a.text = mérő[adat]
|
a.text = mérő[adat]
|
||||||
|
a.tail = '\r\n'
|
||||||
|
|
||||||
print(ET.dump(data))
|
print(ET.dump(data))
|
||||||
print()
|
print()
|
||||||
|
|
||||||
tree = ET.ElementTree(data)
|
tree = ET.ElementTree(data)
|
||||||
tree.write(fileName)
|
tree.write(fileName, encoding="utf-8", xml_declaration=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user