Ich möchte die Daten der einzelnen SKR03 Konten haben.
Ein Auszug asu der Datei sieht so aus:
Code: Alles auswählen
...
</gnc:account>
<gnc:account version="2.0.0">
<act:name>0027 EDV-Software</act:name>
<act:id type="new">8275e7a0b489940a2ba993f9019a898f</act:id>
<act:type>ASSET</act:type>
<act:commodity>
<cmdty:space>ISO4217</cmdty:space>
<cmdty:id>EUR</cmdty:id>
</act:commodity>
<act:commodity-scu>100</act:commodity-scu>
<act:code>0027</act:code>
<act:slots>
<slot>
<slot:key>tax-related</slot:key>
<slot:value type="integer">1</slot:value>
</slot>
</act:slots>
<act:parent type="new">27356188a1963c1dbf943022441d095f</act:parent>
</gnc:account>
<gnc:account version="2.0.0">
...
EDIT: Meine momentane Variante:
Code: Alles auswählen
f = file(SKR_DATEI, "r")
etree = ET.parse(f)
f.close()
root = etree.getroot()
for node in root:
if not node.tag.endswith("account"):
continue
print "_"*79
data = {}
for item in node:
key = item.tag.split("}")[1]
data[key] = item.text.strip()
pprint(data)
Code: Alles auswählen
{'code': '0027',
'commodity': '',
'commodity-scu': '100',
'id': '8275e7a0b489940a2ba993f9019a898f',
'name': '0027 EDV-Software',
'parent': '27356188a1963c1dbf943022441d095f',
'slots': '',
'type': 'ASSET'}