
Standardizing Phone Numbers in a CSV File With Python
Normalize phone numbers to E.164 with a regex and the phonenumbers library; the regex accepted 43.8% more numbers than the library calls valid.
Everything you need to level up your coding skills.

Normalize phone numbers to E.164 with a regex and the phonenumbers library; the regex accepted 43.8% more numbers than the library calls valid.

A 40-line guard for accepting YAML uploads: size cap, UTF-8, safe parsing, expanded-size and depth limits, then key checks. Ten test inputs and what each did.

A CSV has no NULL, so missing arrives as empty, a dash, N/A or null. Inventory the tokens, convert to real NA, keep the reason and see what fillna(0) does.

When a JSON column in PostgreSQL, MySQL or SQLite is enough, and when a document database such as MongoDB earns its place, with measured numbers.

Check an Excel upload before parsing: size, name, zip signature, required parts, macro parts, sheet names and header row, in a fixed order with clear errors.

Let partners add their own data to your XML format safely by giving each extension its own namespace, with a reader that ignores what it does not own.

Why the PostgreSQL planner estimates the wrong number of rows: stale statistics, skew, correlated columns, expressions and parameters, with the fix for each.

Parse $1,234.50, (12.50), 1.234,50 € and 7,00 into exact Decimals, find the cases where stripping symbols is wrong, and spot a column that mixes currencies.

Read password protected Excel files from a script with msoffcrypto-tool, tell file encryption from sheet protection, and keep passwords out of code and logs.

Four formats in one date column, 959 values that are not dates and 15,642 that could be read two ways. Parse with explicit formats and report what you cannot.

Text and elements side by side look natural in documents and break data models. How ElementTree and lxml expose text and tail, and what to do instead.

What to do when a token lands in a values or config YAML: removing it from the file leaves it in history, gitleaks finds it, and rotation is the real fix.
We send one email when a new article is published. No spam.