Skip to content

fix: handle BOM in normalized CSV reader - #486

Open
Gabrymi93 wants to merge 1 commit into
mainfrom
fix/normalized-csv-bom-handling
Open

Gabrymi93 wants to merge 1 commit into
mainfrom
fix/normalized-csv-bom-handling

Conversation

@Gabrymi93

Copy link
Copy Markdown
Member

Problem

When , the Python is used instead of DuckDB's . If the CSV file has a UTF-8 BOM (), the BOM bytes are included in the first field, which can cause issues.

Some data sources (e.g., MEF Dipartimento Finanze) emit CSV files with BOM encoding.

Fix

Use encoding in which automatically strips the BOM if present, while being identical to for files without BOM.

Testing

  • All existing tests pass (, )
  • Verified with MEF IVA sez.att CSV files that have BOM encoding
  • No behavior change for files without BOM

When normalize_rows_to_columns=true, the Python csv.reader is used
instead of DuckDB's read_csv. If the CSV file has a UTF-8 BOM
(\xef\xbb\xbf), the BOM bytes would be included in the first field.

Use utf-8-sig encoding which automatically strips the BOM if present,
while being identical to utf-8 for files without BOM.

This fixes reading of CSV files from sources like MEF Dipartimento
Finanze that emit BOM-encoded CSVs.
@Gabrymi93
Gabrymi93 force-pushed the fix/normalized-csv-bom-handling branch from 9076878 to ecc67f5 Compare September 21, 2026 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant