Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4405a19633 |
@@ -11,6 +11,7 @@ import xml.etree.ElementTree as ET
|
|||||||
import csv
|
import csv
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------------- #
|
||||||
@@ -182,24 +183,31 @@ while fileNameNotFound:
|
|||||||
if not os.path.exists(fileName):
|
if not os.path.exists(fileName):
|
||||||
fileNameNotFound = False
|
fileNameNotFound = False
|
||||||
|
|
||||||
|
print()
|
||||||
print(f'Fájl mentése ide: {fileName}')
|
print(f'Fájl mentése ide: {fileName}')
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# --------------------------------- Write xml -------------------------------- #
|
# ------------------------------- Generate 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))
|
xmlString = ET.tostring(data)
|
||||||
|
|
||||||
|
# ------------------------------- Prettify xml ------------------------------- #
|
||||||
|
|
||||||
|
bs_data = BeautifulSoup(xmlString, 'xml')
|
||||||
|
prettyXml = bs_data.prettify()
|
||||||
|
|
||||||
|
print(prettyXml)
|
||||||
print()
|
print()
|
||||||
|
|
||||||
tree = ET.ElementTree(data)
|
# --------------------------------- Save file -------------------------------- #
|
||||||
tree.write(fileName, encoding="utf-8", xml_declaration=True)
|
|
||||||
|
f = open(fileName, "x")
|
||||||
|
f.write(prettyXml)
|
||||||
|
f.close
|
||||||
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
beautifulsoup4
|
||||||
|
lxml
|
||||||
Reference in New Issue
Block a user