Backend take-home · 120 minutes
CSV import into a database
You have two hours to write a command-line tool that imports a CSV file of customers into a database, in the language you would use at work. Each row has an email, a name, a country code and a signup date. The file can be large, so the tool must not load it all into memory. Some rows are broken. Running the tool twice on the same file must not create duplicates. At the end it prints a summary. Use SQLite or PostgreSQL. Make a test file yourself with a few thousand good rows and a few broken ones. Send a repository with a README and tests.
Requirements
- Usage: import <file.csv> [--dry-run]; a missing file or wrong header gives a clear message and a non-zero exit code
- Reads the file as a stream, row by row, so memory stays flat for a file of a million rows
- Validates each row: a valid email, a non-empty name, a two-letter country code, a valid date
- Broken rows are skipped and reported with their line number and the reason; good rows are still imported
- Upsert by email, so a second run updates rows instead of adding duplicates
- Writes in batches inside transactions, not one round trip per row
- Prints a summary: rows read, inserted, updated, skipped, and the time taken
- The repository has a README, tests for the main behavior and a clean commit history
What reviewers look for
What reviewers look for, the checklist and the stretch goals opens with a year in the app. What a year includes