I am using the Activity-Browser and I would like to import a local dataset into my database. My file has xml format. I can not figure out how to import this format. Is there a way to do it or can I do it with python code?
My Data is from: https://www.probas.umweltbundesamt.de/php/prozessdetails.php?id={9FB8299D-EEFF-4D3C-B17C-6085B278C01A}#nachoben. The xml file there is the one I would like to import. I already tried with xml.etree.ElementTree to write the data into pandas but it's not working how I expect. What would be the way to write a database with python into bw? How does my database have to look?
My code looks like this:
#import packages
import xml.etree.ElementTree as ET
import pandas as pd
#parse the xml file
tree = ET.parse('process.xml')
root = tree.getroot()
#initialize an empty list to store data
A = []
#define a recursive function to parse the xml tree
def parse_element(element, item):
if len(list(element)) == 0:
item[element.tag] = element.text
else:
for child in list(element):
parse_element(child, item)
#iterate through the xml tree and parse the elements
for child in root:
item={}
parse_element(child, item)
A.append(item)
df = pd.DataFrame(A)
I am not aware of any way to import XLM to AB, it's probably easier to read it in Python and write it to the database with BW than you can use it with AB.
If you need help with that please let me know how your data is structured.