Зачем конвертировать XML в CSV?
XML is the standard export format for ERPs, CRMs, bank systems, and government portals, but its tag structure makes it awkward to analyse in a spreadsheet or load into a database. Converting to .CSV gives a flat, row-column layout that any tool can import without further transformation. The conversion works well as long as the XML has a regular, table-like structure.
Способы конвертации XML в CSV
Microsoft Excel - Power Query BUILT-IN
Go to Data > Get Data > From File > From XML, pick the repeating element in Power Query, then File > Save As > CSV.
OpenOffice.org Calc FREE
Open the xml file in Calc, map elements to columns via the XML source panel, then export as Text CSV (.csv).
Command line - Python CLI
Write a short script using xml.etree.ElementTree and csv.writer, then run it as python convert.py input.xml output.csv.
Программы, которые конвертируют XML
Об этих форматах
Файл XML - это текстовый документ, в котором структурированные данные хранятся во вложенных пользовательских тегах. Поскольку это обычный текст, его открывает любой текстовый редактор -…
Открыть детали .XML →Файл CSV хранит табличные данные в виде обычного текста - по одной строке на запись, значения разделены запятыми (или точкой с запятой в европейских регионах). Его открывает любая…
Открыть детали .CSV →Качество и на что обратить внимание
- CSV is flat - nested XML elements and attributes are either dropped or collapsed into one text value; always inspect the output before relying on it.
- XML namespaces can produce messy column names like
{http://example.com/ns}fieldnamein the output; a preprocessing step that strips namespaces avoids this. - Ensure the tool writes UTF-8 if your
xmlcontains non-ASCII characters - Excel on Windows may default to the system code page and corrupt accented or non-Latin text.
Часто задаваемые вопросы
Does this work for any XML file?
xml does not convert to a useful flat csv automatically.What happens to nested elements?
xmltodict to flatten the structure before writing the csv.