Export Seed Data as CSV
Generate seed data in CSV format for spreadsheet import, data pipeline testing, or bulk loading. Learn how NULL values and special characters are handled.
Detailed Explanation
CSV Output Format
The CSV output format generates comma-separated values with a header row. This format is universally supported by spreadsheets, databases, ETL tools, and data analysis libraries.
Single Table Output
id,first_name,last_name,email,is_active,created_at
1,James,Smith,james.smith42@gmail.com,true,2023-07-15 14:27:38
2,Emily,Garcia,emily.garcia17@outlook.com,false,2022-11-03 09:45:12
3,Robert,,robert.jones5@yahoo.com,true,2024-01-20 18:03:51
Multiple Table Output
When the schema contains multiple tables, each table is preceded by a comment header:
# Table: users
id,first_name,...
# Table: products
id,name,...
Special Value Handling
| Scenario | CSV Representation |
|---|---|
| NULL values | Empty field (no content between commas) |
| Boolean TRUE | true |
| Boolean FALSE | false |
| Strings with commas | Enclosed in double quotes: "New York, NY" |
| Strings with quotes | Quotes escaped by doubling: "He said ""hello""" |
| Strings with newlines | Enclosed in double quotes |
CSV-Specific Considerations
Unlike SQL INSERT output, the CSV format includes all columns including auto-increment IDs. This is because CSV import tools typically need a complete record and some may require an explicit ID even if the database auto-generates it.
Common Import Targets
- PostgreSQL:
COPY table FROM 'file.csv' CSV HEADER; - MySQL:
LOAD DATA INFILE 'file.csv' INTO TABLE ... - SQLite:
.mode csvthen.import file.csv table - Pandas:
pd.read_csv('file.csv') - Excel / Google Sheets: Direct file open or import
When to Choose CSV
CSV is the best format when the consumer is a spreadsheet, a data pipeline, or a bulk import tool that does not accept SQL or JSON. It is also the most compact format for large datasets.
Use Case
Your data team needs sample data in CSV format to test an ETL pipeline that loads records from CSV files into a data warehouse. You need realistic data with proper NULL handling and correctly escaped special characters.