Check the First CSV Header Before Renaming It
A CSV heading can look correct while its decoded name includes a hidden marker. Run a synthetic four-case check before changing the export.

If a CSV column looks present but your reader cannot find its name, inspect the decoded header before renaming it. For a file known to use UTF-8, a leading byte order mark can become part of the first field name when the reader uses plain UTF-8 decoding.
This is one possible cause, not a diagnosis for every missing-column error. Preserve the original export, check its encoding and delimiter, and compare the actual header strings with the names your import expects.
Make the invisible part of the header visible
A contact-import script may expect a column called email. A text editor can show that word while the decoded field is actually \ufeffemail: the same letters with U+FEFF in front. An exact lookup for email does not match that longer string.
Python’s UTF-8 signature codec documentation explains the relevant behavior. The utf-8-sig decoder skips an optional UTF-8 BOM at the beginning of the data. Plain UTF-8 decoding can leave that marker as a character for the CSV reader to interpret.
Look at a representation of the first field, rather than its appearance alone. In Python, repr(reader.fieldnames[0]) can expose an escape sequence that a printed heading conceals. The leading bytes ef bb bf are the UTF-8 signature; their absence does not establish the encoding of an arbitrary file.
Reproduce the difference without a customer export
The following Python 3 example creates two tiny byte strings in memory. Both contain a deliberately fictional address and a text campaign identifier. One includes the UTF-8 BOM. No file is overwritten, no contacts are uploaded and no email is sent.
import codecs
import csv
import io
plain = (
b"email,campaign_id\r\n"
b"alex@example.test,00042\r\n"
)
samples = [
("plain", plain),
("bom", codecs.BOM_UTF8 + plain),
]
for label, raw in samples:
for enc in ("utf-8", "utf-8-sig"):
text = io.StringIO(
raw.decode(enc), newline=""
)
reader = csv.DictReader(text)
row = next(reader)
first = repr(reader.fieldnames[0])
found = "email" in row
print(label, enc, first, found,
row["campaign_id"])
In our local run, both decoders found email in the sample without a BOM. With the BOM present, plain utf-8 produced the first header '\ufeffemail' and the lookup was false. Reading that same sample with utf-8-sig produced 'email' and a true lookup. The campaign identifier remained the string 00042 in all four cases.
Original diagram of the synthetic local example, not a screenshot of a contact importer or customer data.
This establishes how this small example behaves. It does not prove that an application you use mishandles BOMs. Many importers account for them already. Run a permitted sample through your actual receiving workflow before changing its export requirements.
Choose a reader setting before deleting characters
For an existing file whose encoding is known to be UTF-8, open a separate read-only inspection with encoding="utf-8-sig" and newline="", then pass that file object to csv.DictReader. Python’s CSV documentation describes the reader’s header mapping and newline handling. Keep the original bytes available for comparison.
This setting is not automatic detection of every character encoding. If decoding fails, investigate the file’s actual encoding rather than adding errors="ignore" and silently discarding characters. If the entire header becomes one field, check whether the separator is a comma, semicolon or tab. A header with spaces or different capitalization is another distinct mismatch to investigate.
Do not remove every unusual character from every field. A blanket cleanup can alter legitimate names or identifiers, and it does not explain which boundary was wrong. Confirm the specific leading marker and fix the decoding step that handles it.
Also avoid turning this into a rule that every CSV must lose its BOM. Microsoft’s Excel guidance describes opening UTF-8 CSV files saved with a BOM and gives import alternatives for files without one. The right handoff depends on the actual reader. A Python lookup and an Excel opening workflow are different checks.
Leave a small import contract
Record the unchanged file, known encoding, delimiter, expected column names, decoded first header and the receiving application or script version. Repeat the comparison after the change, including a file without a BOM so the fix does not depend on the marker being present.
Once the column names match, check the values separately. Our CSV identifier and date review covers that next boundary. Successfully reading an email column also says nothing about whether a message will arrive; keep email-domain checks separate from delivery tests.

