2
Good afternoon, my friends
All right?
I have an XML file from which I would like to remove the data as shown below and plot in columns, not row by row as the code is performing, in case the data would be side by side (horizontal).
tree =  ET.parse('/content/drive/My Drive/Python/Download CVM/Extract/DFP/00759520191231401/InfoFinaDFin.xml')
root = tree.getroot()
xml_data_to_csv = open('Out.csv', 'w')
list_head=[]
Csv_writer=csv.writer(xml_data_to_csv)
count=0
for element in root.findall('InfoFinaDFin'):
  List_nodes =[]
  #Get head by tag
  if count == 0:
    #get child node
    
    DescricaoConta1 = element.find('DescricaoConta1').text
    List_nodes.append(DescricaoConta1)
    
  
    #Write List_nodes to csv
    Csv_writer.writerow(List_nodes)
  
#close csv file
xml_data_to_csv.close()
Result of the presented code: (I would like you to stay: 1 Row x 859 Columns)
