Lovable prompt to build a CSV import/export feature
CSV features look trivial until someone uploads a file with a BOM, quoted newlines, and three different date formats. This prompt makes Lovable build the mapping step, validation preview, and batched writes explicitly, and pairs export with import so round-tripping a file becomes the acceptance test rather than an afterthought.
Last updated
Add CSV import and export for {{resource}} records to this app.
Import flow: an Import button on the {{resource}} list opens a dialog with a drop zone, the file parses in the browser, and a mapping step shows my CSV headers beside selects for each target column, with obvious names pre-matched. A preview table then shows the first rows with invalid cells highlighted and a count of rows that will be skipped.
Validation: required columns enforced before the confirm button enables, dates accepted in a few common formats and normalized to ISO, numbers stripped of currency symbols, and duplicate detection against an existing unique field with a choice to skip or update.
Write path: inserts batched through the Supabase client in chunks so large files do not stall, a progress bar advancing per batch, and an import_runs table recording file name, row counts, and a JSON list of skipped rows I can download afterward.
Export: an Export button that respects the currently applied filters and sort, writes the visible columns to a CSV named with today's date, quotes fields containing commas, and prefixes a BOM so spreadsheet apps detect the encoding.
Edge cases: a file with a BOM, quoted fields containing embedded newlines, a header-only file, and a completely empty file must each produce a clear message rather than a crash.
Acceptance: importing the exported file back produces zero new rows when update-on-duplicate is chosen, skipped rows appear in the downloadable report, and a malformed file never leaves partial data behind, either the batches complete or the report states exactly what landed.Customize it
Runs in your browser. Nothing you type here is sent anywhere.
Add CSV import and export for users records to this app. Import flow: an Import button on the users list opens a dialog with a drop zone, the file parses in the browser, and a mapping step shows my CSV headers beside selects for each target column, with obvious names pre-matched. A preview table then shows the first rows with invalid cells highlighted and a count of rows that will be skipped. Validation: required columns enforced before the confirm button enables, dates accepted in a few common formats and normalized to ISO, numbers stripped of currency symbols, and duplicate detection against an existing unique field with a choice to skip or update. Write path: inserts batched through the Supabase client in chunks so large files do not stall, a progress bar advancing per batch, and an import_runs table recording file name, row counts, and a JSON list of skipped rows I can download afterward. Export: an Export button that respects the currently applied filters and sort, writes the visible columns to a CSV named with today's date, quotes fields containing commas, and prefixes a BOM so spreadsheet apps detect the encoding. Edge cases: a file with a BOM, quoted fields containing embedded newlines, a header-only file, and a completely empty file must each produce a clear message rather than a crash. Acceptance: importing the exported file back produces zero new rows when update-on-duplicate is chosen, skipped rows appear in the downloadable report, and a malformed file never leaves partial data behind, either the batches complete or the report states exactly what landed.
Same task in other tools
Questions about this prompt
Does parsing happen in the browser or an edge function?
In the browser, which keeps large files off the function and gives instant mapping feedback. The Supabase writes are the only server work, batched so a big import never holds one long request open.
How do I adapt this for a fixed CSV format from another system?
Tell Lovable the exact header names and skip the manual mapping UI, going straight to the validation preview. Keep the skipped-rows report, fixed formats still arrive with broken rows.
Imports die partway through big files. What should I check?
Look at the batch size and whether one failed chunk stops the loop without recording progress. Ask Lovable to write each batch to import_runs as it lands so a retry resumes instead of duplicating rows.