Skip to content
Advertisement

Create a DataFrame from a XML File

im new to XML and i want to know how to create a dataframe in python from this XML file.

JavaScript

I have the following code, it creates the DataFrame but when i tried to append the value of the row, i dont know why it keeps coming “None”.

I dont know if i have to change de calling argument i.e Attrib.get.

Also i tried changing the attrib.get to find(“value”).text but it give me the error that it dosnt have the a text attribute.

JavaScript

this is the printout of print(rows) [{‘guid’: None, ‘status’: None, ‘forma_pago’: None, ‘monto’: None, ‘monto_abono’: None, ‘entidad’: None, ‘tipo’: None, ‘balance’: None, ‘KIND_ID’: None, ‘TYPE_ID’: None, ‘CUSTOMER_ID’: None, ‘MEMBER_TYPE’: None}]

and this is the printout of the dataframe guid status forma_pago monto monto_abono entidad tipo balance KIND_ID
0 None None None None None None None None None

TYPE_ID CUSTOMER_ID MEMBER_TYPE
0 None None None

Advertisement

Answer

Here is a working solution:

1/ remove top line from xml file, I am unsure if the first tag is xml compliant ?

JavaScript

2/ code:

JavaScript

3/ output for out_df:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement