ver Mar10th
changed AT element filtering
This commit is contained in:
22
at_processing/ubuntu_node_statistics.py
Normal file
22
at_processing/ubuntu_node_statistics.py
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import lxml.etree
|
||||
from lxml.etree import _Element
|
||||
from typing import Counter
|
||||
import json
|
||||
import collections
|
||||
|
||||
file_name = "w0"
|
||||
|
||||
with open("{:}.json".format(file_name)) as f:
|
||||
xml_str: str = json.load(f)["AT"]
|
||||
root: _Element = lxml.etree.fromstring(xml_str)
|
||||
with open("{:}.xml".format(file_name), "w") as f:
|
||||
f.write(lxml.etree.tostring(root, encoding="unicode", pretty_print=True))
|
||||
#root: _Element = lxml.etree.parse("{:}.xml".format(file_name)).getroot()
|
||||
node_types: Counter[str] = collections.Counter()
|
||||
for n in root.iter():
|
||||
node_types[n.tag] += 1
|
||||
|
||||
for n in sorted(node_types):
|
||||
print(n, node_types[n])
|
||||
Reference in New Issue
Block a user