Splinter is a CLI utility written in Go for splitting large CSV files into parts by a specified number of rows. Each part preserves the original CSV header and column order.
go build -o ./bin/splinter ./cmd/splinterOr install globally:
go install ./cmd/splinterAfter installation, the binary will be placed in $GOPATH/bin/splinter (or $HOME/go/bin/splinter if GOPATH is not set).
To use it, make sure $GOPATH/bin (or $HOME/go/bin) is in your PATH. You can add it to your shell profile:
# For bash/zsh
export PATH=$PATH:$(go env GOPATH)/binOr call it directly with the full path: $(go env GOPATH)/bin/splinter
splinter -f <file> -n <row_count> -o <output_directory> [-s <separator>]-f, --file(required) - Path to the CSV file to split-n, --rows(required) - Number of rows per split file (excluding header)-o, --output(required) - Directory to save the split parts-s, --separator(optional) - CSV field separator (default:,)-h, --help- Show usage help
Split file data.csv into parts of 1000 rows each:
splinter -f data.csv -n 1000 -o output/Using long flags:
splinter --file large.csv --rows 500 --output parts/Split a semicolon-separated file:
splinter -f data.csv -n 1000 -o output/ -s ";"Show help:
splinter -h
# or
splinter --help
# or simply
splinterWhen splitting a file example.csv, the following files will be created:
example_1.csvexample_2.csvexample_3.csv- etc.
Each file contains:
- Original CSV header
- Specified number of data rows (or fewer for the last file)
- Preserved column order
splinter/
├── cmd/
│ └── splinter/
│ └── main.go # Entry point, argument parsing
├── internal/
│ └── splitter/
│ └── splitter.go # CSV splitting business logic
├── go.mod
└── README.md
- Go 1.21 or higher
The project uses only the Go standard library:
flag- for CLI flag handlingencoding/csv- for CSV file operationsos,path/filepath- for filesystem operations