Random CSV Data Generator for Import Testing
Generate and download CSV contact fixtures. Test header mapping, quoting, Unicode and spreadsheet behavior before a bulk import.
Preview
Example| name | |
|---|---|
| Tess Example | [email protected] |
Test fixture
"name","email"
"Tess Example","[email protected]"Create a CSV file for an import preview
Generate a few rows and download CSV to get a header and contact records. Start with a small file while configuring column mappings. Load the records with a proper CSV reader and verify the field called email lands in the intended destination. Keep the same header names in the positive fixture across test runs.
Save one file without a required column and another with its columns in a different order. Importers that use labels should accept the reordering. Compare the error returned for the missing column to the error for a malformed row. Review how the UI reports source row numbers when a batch contains both valid and invalid records.
Cover delimiters and spreadsheet formatting
Edit a local copy to include a value with a comma, a quote and a newline. Fields containing punctuation must round trip without creating extra columns. Check Unicode names in your spreadsheet application and set UTF-8 explicitly in command line tests. Treat identifiers as text to preserve leading zeros. Use a small numeric-looking string to detect silent type conversion.
MockXYZ quotes CSV cells and adds an apostrophe before certain formula-like string values to help reduce spreadsheet formula execution. Check how your specific import target handles this protective prefix before asserting exact equality. Keep untrusted spreadsheets isolated when exercising formula handling.
Check rollback and retries
Use the example to validate the file before handing it to the import runner. Then build an integration test that imports the same file twice and checks the product’s chosen duplicate behavior. If the import can partially succeed, include a failing row in the middle of the file and verify which records are retained. Add a large generated batch only after the small cases are stable so a failed load is easy to diagnose.
Keep an untouched sample in source control before opening it in a spreadsheet. Saving a file from that application can change delimiters, line endings or encoding.
Python test example
import csv
from pathlib import Path
with Path('random-csv-data.csv').open(encoding='utf-8', newline='') as file:
reader = csv.DictReader(file)
assert reader.fieldnames == ['name', 'email']
rows = list(reader)
assert rows and all(None not in row and row['email'] for row in rows)
print(f'{len(rows)} contact fixtures')