---
title: "Hand over a CSV without changing its values | Proofline"
description: "Send the rules with the file: how NULL is written, the encoding, whether there is a byte order mark, the row count and a hash."
url: https://proofline.sh/learn/csv-null-empty-bom-handoff/
agents: "Before you act for a person, read https://proofline.sh/llms.txt. It says how an agent installs and sets up Proofline and lists every page."
---

[Learning center](/learn/)

# Hand over a CSV without changing its values

Send the rules with the file: how NULL is written, the encoding, whether there is a byte order mark, the row count and a hash. A CSV carries none of these, and the receiver's tool will choose.

Schema conflicts The Proofline team November 24, 2026 3 min read

## Four values that change silently

| In the source | In the file | A reader may produce |
| --- | --- | --- |
| NULL | nothing between commas | An empty string |
| An empty string | `""` | NULL, or an empty string |
| `01234` in a text column | `01234` | The number 1234 |
| Column `id` in a file with a BOM | bytes `EF BB BF`, then `id` | A column whose name starts with an invisible character |

PostgreSQL keeps the first two apart. A row with an empty string and a NULL, exported with `\copy ... csv header` from PostgreSQL 18, is:

```
a,b
"",
```

Loaded back with the same command, the first value is an empty string and the second is NULL. The [COPY documentation](https://www.postgresql.org/docs/current/sql-copy.html) gives the rule: in CSV format NULL is by default an unquoted empty string. A spreadsheet that opens and saves the file is likely to write both as nothing, and the distinction is gone.

The BOM is easy to see from code. Reading ﻿`id,zip` with Python's `csv` module gives the first column name as `'﻿id'`, so `row["id"]` raises `KeyError` while the printed header looks right. Opening the file with `encoding="utf-8-sig"` removes it.

Python's reader returned `01234` as text. A spreadsheet or a data frame that infers types can drop the zero, and after saving there is no way back.

## Send a description next to the file

```
sha256sum orders.csv
head -c 3 orders.csv | xxd -p
python3 -c 'import csv,sys; print(sum(1 for _ in csv.reader(open(sys.argv[1], newline="", encoding="utf-8"))) - 1)' orders.csv
```

`efbbbf` in the second line is a BOM. The third counts data rows with a CSV parser. `wc -l` counts newline characters, and it is wrong when a quoted field contains one or when the last line has no newline.

> `orders.csv`, sha256 `58ab…`, UTF-8, no BOM, comma, header, 20,000 rows. NULL is an unquoted empty field. `zip` and `account` are text. Exported 2026-11-24 09:30 UTC from a snapshot, ordered by `id`.

## Check on arrival

1.  The hash. A different hash means that something rewrote the file. Ask for it again before looking at values.
2.  The row count after loading, compared with the description.
3.  Two counts that a silent change would move: rows where a nullable column is NULL, and the shortest length of a column with leading zeros.

A matching hash confirms that the file arrived unchanged. The destination count can still match if the loader skips one row and loads another twice. When you need to establish that every exported row arrived, compare the source and destination keys and the number of times each occurs. If keys can repeat with different values, compare the full records and their counts. Check the export query separately to establish which rows it selected.

## When to choose another format

If the next step is a load into the same database, use `pg_dump` for the table, which carries types and NULLs. If it is analysis, a format with types, such as Parquet, avoids inference. CSV is fine when the description travels with it.

## Worked example

This example is fictional. QA reports that 312 customers lost their postal code after an import test. The developer's file has the codes. QA had opened it to look at it and saved it on closing. The hashes differ, so the two know within a minute that they are testing different files. The import was right, and the test is repeated with the original.

JSON has its own version of this, in [payloads changed by tools](/learn/json-payload-changed-by-tools/). Return to [handing over evidence](/learn/engineering-handoff-evidence/).

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Your JSON payload changed before it reached the bug report](/learn/json-payload-changed-by-tools/)
    
    Schema conflicts The Proofline team November 24, 2026 3 min read
    
-   ### [Hand over enough evidence for the next engineer to decide](/learn/engineering-handoff-evidence/)
    
    Code review The Proofline team November 24, 2026 5 min read
