
Writing a DataFrame to Excel With Formatting in pandas
Format a pandas DataFrame in Excel with XlsxWriter: header style, number and date formats, auto-fit widths, a table with banding and conditional formatting.
Everything you need to level up your coding skills.

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

A NUL byte can cut a PostgreSQL load short while Python keeps it. Find them with grep, strip them from 130 MB in under a second, and keep tabs and newlines.

Get fast with psql: meta commands, a psqlrc, expanded output and pagers, scripts, variables, timing, editor integration, output to files and pgpass.

A UTF-8 byte order mark in front of JSON breaks strict parsers in Python and Node. What the three bytes are, who adds them and how to read or remove them.

Excel on Windows often shows UTF-8 accents as à symbols. Add a BOM when you write the file, or import it with the right encoding, and check the bytes first.

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

When an XML feed mixes encodings or was encoded twice: why detectors guess wrong on short text, the UTF-8 first rule and per-line fallback.

Repair text like José inside a CSV by reversing the wrong decode, with ftfy or two lines of Python, and learn which garbling can never be undone.

Why a line indented between two levels raises did not find expected key, how PyYAML words it differently, and how to realign. Output from three parsers.

Export SQL results to Excel that open cleanly: keep types and dates, carry formatting, use several sheets, resist formula injection and run on a schedule.

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.

Convert a legacy CSV to UTF-8 with iconv or Python, choose between Latin 1 and Windows 1252, and handle the five bytes Windows 1252 leaves undefined.
We send one email when a new article is published. No spam.