
YAML Error Could Not Find Expected Colon and Its Causes
A line with a word and no colon makes the parser fail while scanning a simple key. See the message in three parsers, the usual causes and the fixes.
Tag
93 posts

A line with a word and no colon makes the parser fail while scanning a simple key. See the message in three parsers, the usual causes and the fixes.

When a minified XML file will not parse, xmllint --format and lxml refuse to indent it. A 30-line tokenizer indents what it can and flags the first mismatch.

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.

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.

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.

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.

Repair a 29 MB XML export with 215,385 raw ampersands using a lookahead regex that leaves existing entities alone, with the cases that need judgment.

Three invisible bytes at the start of a CSV can fix Excel or break a header match. See which readers strip a BOM and how to add or remove one.