Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python xml to csv

try:
    import xml.etree.cElementTree as ET
except ImportError:
    import xml.etree.ElementTree as ET
import pandas as pd

tree = ET.parse("file1.xml")
root = tree.getroot()
iter_root = root.iter()

l = {}
for elem in iter_root:
    l[str(elem.tag)] = str(elem.text)

df = pd.DataFrame.from_dict(l,orient="index")

df.to_csv('ABC.csv')
Comment

python code to convert csv to xml

with open('output.xml', 'w') as f: f.write('
'.join([convert_row(row) for row in data[1:]]))
Comment

PREVIOUS NEXT
Code Example
Python :: how to use path to change working directory in python 
Python :: datafram combine 3 columns to datetime 
Python :: send message from server to client python 
Python :: Pyspark Aggregation on multiple columns 
Python :: python list 
Python :: heroku python buildpack 
Python :: python switch case 3.10 
Python :: pytthon remove duplicates from list 
Python :: create app in django 
Python :: reshape wide to long in pandas 
Python :: como comentar en Python? 
Python :: first and last digit codechef solution 
Python :: how to hide tensorflow warnings 
Python :: add time and date to datetime 
Python :: data structures and algorithms in python 
Python :: initialise a 2d array python 
Python :: data compression in python 
Python :: numpy.ndarray to lsit 
Python :: python find largest variable 
Python :: python list transpose 
Python :: multiple boxplots python 
Python :: how to have requirement file in python for libs 
Python :: install python in docker file 
Python :: directory path with python argparse 
Python :: get an item out of a list python 
Python :: dataset for cancer analysis in python 
Python :: int to ascii python 
Python :: Play Audio File In Background Python 
Python :: run matlab code in python 
Python :: python b before string 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =