
Building Idempotent CSV Imports That Are Safe to Run Twice
Four ways to make a CSV import safe to rerun, tested on one three-row file run twice: upsert on a key, row hash, replace by batch and a content-hash ledger.
Tag
590 posts

Four ways to make a CSV import safe to rerun, tested on one three-row file run twice: upsert on a key, row hash, replace by batch and a content-hash ledger.

Four ways to load a CSV stored in S3 into a database: a streamed pipe, the RDS aws_s3 extension, DuckDB reading s3:// directly, and a download-then-load job.

A complete psycopg 3 script that stages a daily CSV with COPY, merges it with an upsert, records a content hash, and is safe to run again after a failure.

Build a CSV import job that runs unattended: idempotent loads, one transaction, reject files, an archive, a ledger, locking, alerts and a safe backfill.

A short Python scanner that flags base64 blobs, percent-encoded text, script tags, formula starts and oversized fields in a CSV before you import it.

Email is a poor way to move a CSV of real data. Ranked alternatives, from not sending it to expiring links, plus how to encrypt a file you must attach.

The GDPR duties that land on a CSV of customer data, from minimization and retention to access requests and deletion, turned into practical engineering steps.

A plain SHA-256 of an email is reversible with a guess list. Use a keyed HMAC for tokens and partial masking for display, with a script that does both.

Export invoices and lines to Excel so totals add up: one row per line, tax by a stated rule, document totals checked, no gaps in numbering and exact decimals.

Map XML to Java classes with Jakarta XML Binding, read attributes, lists and optional elements, and see a bad boolean and a bad number accepted silently.

Remove, generalize and pseudonymize the personal columns of a CSV with DuckDB before it leaves your team, then check that no one can still be singled out.

JSONPath, JMESPath, jq and the path dialects of PostgreSQL, MySQL and SQLite tested on one document: syntax, null handling, speed, indexes, portability.