Implement or refactor data import/parsing so it streams files sequentially (memory-safe), validates/coerces types explicitly, skips irreparable records while logging them to an error CSV (full original columns + timestamp/file/line/error), emits rows_ok/rows_skipped/parse_errors metrics, and guarantees idempotent DB writes.
Implement or refactor data import/parsing so it streams files sequentially (memory-safe), validates/coerces types explicitly, skips irreparable records while logging them to an error CSV (full original columns + timestamp/file/line/error), emits rows_ok/rows_skipped/parse_errors metrics, and guarantees idempotent DB writes.
Also in this package
Other skills from janjaszczak/cursor · top by installs.
Irreparable records must be skipped and logged to an error CSV containing:
- all original columns exactly as seen in input - extra columns: timestamp, file, line, error
Emit metrics at minimum: rowsok, rowsskipped, parse_errors.
DB writes must be idempotent: re-running the import must not duplicate or corrupt data.
Standard workflow
1) Plan-first (before coding)
Identify input formats, volume, and “row identity” rules (keys/dedup strategy).
Locate current import entrypoints + DB write layer.
Define:
- schema mapping (source -> target columns) - validation rules per field - coercion rules per field (what is allowed, what is not) - error taxonomy (what counts as “irreparable”)
2) Streaming architecture
Read one file at a time, row by row (or chunked) and write in bounded batches.
Never accumulate full datasets in memory.
Ensure progress logging is monotonic (e.g., file + row counters).
3) Validation & coercion
Treat raw row values as immutable “source of truth”.
Perform coercions in a controlled layer:
- return (ok, parsed_record) or (error, reason) per row