我一直在尝试通过 xmltodict.parse 函数将我的所有日志转换为字典
问题是,当我尝试将单行转换为变量时,它工作正常
a = xmltodict.parse(df['CONFIG'][0])
和...一样
已解析[1] = xmltodict.parse(df['CONFIG'][1])
但是当我尝试迭代整个数据框并将其存储在字典中时,我得到以下信息
for ind in df['CONFIG'].index:
parsed[ind] = xmltodict.parse(df['CONFIG'][ind])
---------------------------------------------------------------------------
ExpatError Traceback (most recent call last)
/tmp/ipykernel_31/1871123186.py in <module>
1 for ind in df['CONFIG'].index:
----> 2 parsed[ind] = xmltodict.parse(df['CONFIG'][ind])
/opt/conda/lib/python3.9/site-packages/xmltodict.py in parse(xml_input, encoding, expat, process_namespaces, namespace_separator, disable_entities, **kwargs)
325 parser.ParseFile(xml_input)
326 else:
--> 327 parser.Parse(xml_input, True)
328 return handler.item
329
ExpatError: syntax error: line 1, column 0