{"success":true,"name":"parse-csv-imports-defensively-real-files-are-always-messy","description":"Importing data from CSV/Excel files users provide.","category":"ai-brimind","path":"ai-brimind/parse-csv-imports-defensively-real-files-are-always-messy/SKILL.md","file":"SKILL.md","content":"---\nname: parse-csv-imports-defensively-real-files-are-always-messy\ndescription: \"Importing data from CSV/Excel files users provide.\"\n---\n\n# Parse CSV Imports Defensively — Real Files Are Always Messy\n\n## When to use\nThe system reads CSV or spreadsheet files from users/clients, and the parser assumes clean, well-formed, correctly-encoded input.\n\n## Example request\nsplit(',') used as the parser → a name containing a comma ('Dupont, Ali') shifts every column after it — quoting rules ignored. File saved from Excel in French locale → semicolon-separated with comma decimals; the import reads garbage — delimiter and locale assumptions. Row 4832 has an empty required cell → the import crashes at 60% leaving half the data inserted — no row-level error handling.\n\n## Instructions\nAct like a developer who has seen what Excel does to files and trusts nothing about an import. Rules: (1) NEVER hand-parse with split — use a real CSV library that handles quoting, escaped quotes, embedded commas and newlines; hand-rolled parsing works until the first real name with a comma; (2) detect the dialect — delimiter (comma vs semicolon, common in French/European locales), encoding (UTF-8 vs legacy encodings that turn accents into garbage — check before inserting, not after), and header row presence; validate headers against expected column names and fail with a helpful message listing what's missing; (3) process ROW BY ROW with per-row validation — a bad row is recorded (row number + reason) and skipped or queued, never allowed to crash the batch; decide upfront: all-or-nothing (transaction, reject file on any error) or best-effort (import valid rows, report the rest) — and tell the user which; (4) end with an honest report: N imported, N skipped with downloadable reasons, N duplicates — an import that says only 'done' hides its failures; make the import idempotent (dedupe key) because the user WILL upload the same file twice. Only proceed once a file with commas-in-values, wrong encoding, a missing column, and a duplicate upload all produce correct, explained outcomes.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1180\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}