0
A
回答
1
首先,你需要解析你的XML文件。這可以通過ElementTree API來完成:
示例代碼:
import xml.etree.ElementTree as ET
root = ET.parse('your_data.xml').getroot()
with open("output.csv", "w") as file:
for child in root:
print(child.tag, child.attrib)
# naive example how you could save to csv line wise
file.write(child.tag+";"+child.attrib)
There are also solutions to parse your XMLs directly as dictionary.
然後csv.DictWriter可用於保存字典作爲CSV。
相關問題
- 1. 如何使用python將大型Json文件轉換爲csv
- 2. 使用python將xml文件轉換爲csv文件
- 3. 使用Python將XML轉換爲CSV
- 4. 使用SAX將XML轉換爲CSV Python
- 5. 將大型JSON轉換爲CSV - Python
- 6. 將大型XML文件轉換爲Excel
- 7. 如何將大型XML文件轉換爲JSON文件?
- 8. 如何使用python將.txt文件轉換爲xml文件?
- 9. 如何使用XSLT 1.0將.csv文件轉換爲xml?
- 10. 如何使用PHP腳本將CSV文件轉換爲XML?
- 11. 如何將大型XML數據轉換爲Excel或CSV
- 12. 我如何使用python將複雜.mat文件轉換爲csv
- 13. 如何使用python將XLSB文件轉換爲csv?
- 14. Perl:將csv文件轉換爲xml
- 15. 將CSV文件轉換爲XML
- 16. 將XML文件轉換爲CSV
- 17. 使用java將XML文件轉換爲CSV文件
- 18. 使用Argparse轉換XML爲csv在python
- 19. 轉換大型XML文件
- 20. 我該如何將xml文件轉換爲使用python的JSON?
- 21. 使用Python(空閒)將JSON *文件*轉換爲CSV *文件*
- 22. Python - 將csv文件轉換爲JSON
- 23. 將csv文件轉換爲python字典
- 24. Python,將CSV文件轉換爲SQL表
- 25. Python:如何將.ofx文件轉換爲.csv文件
- 26. 使用apache駝峯從csv文件類型轉換爲xml
- 27. 如何將Visio文檔.xml轉換爲csv文件c#
- 28. 如何將兩列.csv文件轉換爲xml文檔
- 29. 使用XSLT將XML轉換爲CSV
- 30. 使用PHP將XML轉換爲CSV
沒有關於XML文件結構的任何額外信息,您的問題沒有合理的答案。 –