I’m trying to import two xml files, convert them to dataframes and do some analysis. However, since these are xml’s I need to first convert them to json or excel to be able to create dataframes. With excel files, the file_uploader works directly, however, with xmls, I first need to open, read and then transform.
import xmltodict import json file1 = st.file_uploader('File 1') file2= st.file_uploader('File 2') if st.button('Compare Files'): with open(file1 ,'r',encoding='utf-8') as in_file: xml = in_file.read() file1_data = json.loads(json.dumps(xmltodict.parse(xml)))
When I try the above snippet, the file is taken in as String.IO object and is not able to be read and throws the below error. Did anyone see any similar issue ? Know this is more of an SO post, but I thought putting it here would be more helpful.