
Parsing and Writing XML in Python With ElementTree and lxml
A tested guide to XML in Python: ElementTree versus lxml, reading, streaming, writing, namespaces, validation, XSLT, tables, safety and an end-to-end script.
Tag
134 posts

A tested guide to XML in Python: ElementTree versus lxml, reading, streaming, writing, namespaces, validation, XSLT, tables, safety and an end-to-end script.

Write Excel formulas and number formats from Python with openpyxl and XlsxWriter: English syntax, cached values, table references, percent and date codes.

Build one Excel workbook from several SQL queries: a summary sheet, a sheet per region, formulas that point across sheets and an index with working links.

A response or file that stops mid-document fails with an end-of-input error. How to confirm truncation, salvage complete records and decide on repair.

Export a MySQL query to a clean XLSX with PyMySQL and pandas, handling DECIMAL, zero dates, tinyint flags and utf8mb4, and compare it with Workbench.

Export SQL Server query results to XLSX with pyodbc and pandas, and see what SSMS, bcp and the Import and Export Wizard give you instead.

Format a pandas DataFrame in Excel with XlsxWriter: header style, number and date formats, auto-fit widths, a table with banding and conditional formatting.

Run a PostgreSQL query from Python and write an Excel file with correct types, converting timestamptz, numeric and ids so the workbook opens cleanly.

Extra data means a valid JSON value was followed by more text. Why concatenated objects and JSON Lines trigger it and three ways to read them in Python.

Why json.loads or response.json() raises Expecting value at line 1 column 1 in Python, how to see what the text really is, and a checklist for each cause.

Fix ElementTree ParseError unbound prefix and lxml Namespace prefix is not defined: fragments cut from a document, auto-declared prefixes, recover.

Read every sheet of an Excel workbook with pandas, map each to its own staging table with safe names, skip hidden or unexpected sheets and verify the counts.