Convert CSV files to custom JSON formats using simple templates. Perfect for data transformation or API integration.
- ✅ Zero Code Required - Just configure templates and run
- ✅ Custom JSON Formats - Create any JSON structure you need
- ✅ Batch Processing - Handle multiple CSV files at once
- ✅ Data Type Conversion - Auto-convert to string, int, float, bool, timestamp
- ✅ Template Reuse - Save and reuse templates for different projects
# 1. Process all CSV files (uses default template)
python csv_to_json.py
# 2. Process specific file
python csv_to_json.py --input-file your_file.csv
# 3. Use custom template
python csv_to_json.py --template api_formatThat's it! Your JSON files will be in export_json/ folder.
Simple concept: Map CSV columns to JSON structure using {{type:column_name}} syntax.
Your CSV:
name,age,email
John,25,[email protected]
Template:
{
"full_name": "{{string:name}}",
"years_old": "{{int:age}}",
"contact": "{{string:email}}"
}Result:
[
{
"full_name": "John",
"years_old": 25,
"contact": "[email protected]"
}
]{{string:column}}- Text{{int:column}}- Numbers{{float:column}}- Decimals{{bool:column}}- True/False{{unixtimestamp:column}}- Unix timestamp
your_project/
├── csv_to_json.py # Main script
├── template/import_template.json # Your templates
├── import_csv/ # Put CSV files here
└── export_json/ # JSON output goes here
# Setup: Create template config
python csv_to_json.py --create-config
# Process: Convert all CSV files
python csv_to_json.py
# Check: List available templates
python csv_to_json.py --list-templates
# Custom: Use specific template
python csv_to_json.py --template your_template_name{
"user_name": "{{string:name}}",
"status": "active",
"user_id": "{{int:id}}",
"profile_url": "https://example.com/user/{{string:username}}"
}{
"user": {
"personal": {
"name": "{{string:full_name}}",
"age": "{{int:age}}"
},
"contact": {
"email": "{{string:email}}"
}
}
}- Place CSV files in
import_csv/folder - Run setup:
python csv_to_json.py --create-config - Edit templates in
template/import_template.json(optional) - Convert files:
python csv_to_json.py - Get results from
export_json/folder
| Problem | Solution |
|---|---|
| "Column not found" | Check column names match CSV headers exactly |
| Empty JSON output | Verify CSV has headers and proper format |
| Template not found | Run --list-templates to see available options |
| Date conversion fails | Use {{timestamp:column}} for date fields |
Verify your CSV→JSON conversions are 100% accurate!
# Verify all files
python tests/verify_csv_json.py
# Verify single file
python tests/verify_csv_json.py --file ETH_USDC_Blacklist.csv- Row Count Matching: CSV rows = JSON records
- Data Transformations: All
{{type:column}}mappings work correctly - Type Conversions: String→Int, DateTime→Unix timestamp, etc.
- Static Values: Fixed values in templates (like
"status": "active") - Template Integrity: Every CSV field correctly mapped to JSON
🔍 CSV to JSON Data Integrity Verification
============================================================
📁 Found 9 CSV files to verify
📋 Verifying: ETH_USDC_Blacklist.csv → ETH_USDC_Blacklist.json
✓ CSV loaded: 314 rows
✓ JSON loaded: 314 records
✓ Row counts match: 314 records
✓ Using template with 4 mapped fields
✅ Data verification PASSED - All 314 records match perfectly
📊 VERIFICATION SUMMARY
============================================================
Total files verified: 9
✅ Successful: 9
❌ Failed: 0
📈 DATA STATISTICS:
Total CSV rows processed: 6,837
Total JSON records created: 6,837
🎉 ALL VERIFICATIONS PASSED! Your data integrity is perfect.
- ✅ After first conversion - Ensure everything works correctly
- ✅ Template changes - Verify new mappings work as expected
- ✅ New data files - Check compatibility with existing templates
- ✅ Before production - Final quality assurance step
- ✅ Troubleshooting - Identify specific data issues
# Verify all CSV/JSON pairs
python tests/verify_csv_json.py
# Verify specific file
python tests/verify_csv_json.py --file your_file.csv
# Use custom template for verification
python tests/verify_csv_json.py --template custom_template.json- Test first: Use
--input-file single.csvto test templates - Check headers: Column names in template must match CSV exactly
- Backup data: Keep original CSV files safe
- Start simple: Use
--create-configfor basic setup - Verify always: Run verification after any template changes
Ready to convert your CSV files to custom JSON formats! 🚀