A high-performance CSV parser for cricket ball-by-ball data, designed to efficiently import large datasets into PostgreSQL.
- Concurrent processing with configurable worker count
- Batch inserts using PostgreSQL's COPY protocol for maximum performance
- Support for multiple leagues (WPL, IPL, BBL, WBBL, SA20)
- Skip existing data to avoid duplicate imports
- Progress tracking with processing rate statistics
- Go 1.21 or later
- PostgreSQL database with the schema matching the Prisma schema
cd boundary-bytes-parser
go mod tidy
go build -o bin/seeder ./cmd/seederCreate a .env file in the project root or set the DATABASE_URL environment variable:
DATABASE_URL="postgresql://user:password@localhost:5432/database"Process all leagues:
./bin/seederProcess a specific league:
./bin/seeder -league WPL
./bin/seeder -league IPL
./bin/seeder -league BBL
./bin/seeder -league WBBL
./bin/seeder -league SA20Custom CSV directory:
./bin/seeder -csv-dir /path/to/csv/filesAdjust concurrency:
./bin/seeder -concurrency 8Force processing even if data exists:
./bin/seeder -skip-existing=false| Flag | Default | Description |
|---|---|---|
-league |
(all) | League to process: WPL, IPL, BBL, WBBL, or SA20 |
-csv-dir |
current directory | Base directory containing CSV folders |
-concurrency |
number of CPUs | Number of concurrent workers |
-skip-existing |
true | Skip leagues that already have data |
The parser expects the following directory structure:
csv-dir/
├── wpl_csv2/
│ ├── 123456.csv # Ball-by-ball data
│ ├── 123456_info.csv # Match metadata
│ └── ...
├── ipl_csv2/
│ └── ...
├── bbl_csv2/
│ └── ...
├── wbb_female_csv2/
│ └── ...
└── sat_male_csv2/
└── ...
The Go implementation provides significant performance improvements over the TypeScript/Prisma version:
- Uses PostgreSQL's COPY protocol for bulk inserts (~10x faster than individual INSERTs)
- Concurrent file processing
- Memory-efficient streaming CSV parsing
- Connection pooling for database operations
Typical performance on a modern machine:
- ~100+ matches per second
- ~50,000+ deliveries per second
boundary-bytes-parser/
├── cmd/
│ └── seeder/
│ └── main.go # Entry point
├── internal/
│ ├── database/
│ │ └── database.go # Database operations
│ ├── models/
│ │ └── models.go # Data structures
│ ├── parser/
│ │ └── parser.go # CSV parsing logic
│ └── seeder/
│ └── seeder.go # Orchestration logic
├── go.mod
├── go.sum
└── README.md
# Development build
go build -o bin/seeder ./cmd/seeder
# Production build with optimizations
go build -ldflags="-s -w" -o bin/seeder ./cmd/seedergo test ./...The parser writes to the following tables (matching the Prisma schema):
wpl_match- Match basic info (id, league, season, start_date, venue)wpl_delivery- Ball-by-ball datawpl_match_info- Match metadatawpl_team- Teams per matchwpl_player- Players per matchwpl_official- Match officialswpl_person_registry- People registry IDs
The Go parser is a direct replacement for the TypeScript seed scripts in prisma/seed.ts and prisma/seed-multi-league.ts. It maintains the same database schema and data format while providing better performance for large datasets.