草庐IT

nodewriter

全部标签

python - 如何将多个 XML 文件解析为多个 CSV 文件?

我使用此代码解析了XML文件,该代码适用于单个xml输入到单个csv输出。我尝试使用glob处理多个输入以及多个csv输出,但我知道这是不正确的。importglobimportxml.etree.ElementTreeasetimportcsvforfileinglob.glob('./*.xml'):withopen(file)asf:tree=et.parse(f)nodes=tree.getroot()withopen(f'{f[:-4]}edited.csv','w')asff:cols=['dateTime','x','y','z','motion','isMoving',