How to handle missing or empty values in a CSV file
The difference between a truly empty field, a literal 'NULL'/'N/A' string, and a missing column — and how each one behaves differently when imported.
Before you work through this by hand: you can check your own CSV free and see which of these problems your file actually has — duplicate rows, near-duplicates, broken quoting, encoding damage. It runs in your browser tab, nothing is uploaded, and there's no signup or email.
Three different things that all look "missing"
A CSV field can be missing in several distinct ways that look similar but behave differently downstream: a truly empty field (two commas with nothing between them, ,,), a field containing the literal text "NULL", "N/A", "NA", or "-", and a row that's simply shorter than the header (missing a trailing column entirely). Tools differ on how they treat each one.
Why this matters for imports
Some import tools treat an empty field as a database NULL automatically; others store it as an empty string, which is not the same thing for filtering/matching later. A literal text value like "N/A" is neither — it's a real string value that happens to mean "missing," and most tools won't recognize it as empty unless you tell them to.
Standardizing missing values with pandas
import pandas as pd; df = pd.read_csv('file.csv', na_values=['N/A', 'NA', 'NULL', '-', '']) — this tells pandas to treat all of those variants as a true missing value (NaN) consistently, rather than leaving some as literal text strings.
Deciding what to do with missing values
Once identified consistently, the right handling depends on the field: sometimes a missing value should become a default (like assuming a missing "country" is unknown), sometimes the whole row should be flagged for review rather than silently guessed at, and sometimes it's fine to just leave it blank in the output. There's no universal right answer — but it should be a deliberate choice, not an accident of which literal string your source system happened to use.
Checking during cleanup
This is worth checking alongside the other items on our CSV cleanup checklist, especially before deduplication — two rows that differ only in whether a field is truly empty vs. the text "N/A" can incorrectly look like different records.
See CSV Repair & Deduper (offline browser tool) — $19 one-time