splitcsv

module
v0.0.0-...-1964bd6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2026 License: MIT

README

SplitCSV

CI Go Report Card

Split a CSV file into one or more parts. The header is written to every output file; data rows are distributed round-robin.

Features

  • Round-robin distribution — rows are spread evenly across output files
  • Header in every file — each part is a valid, self-contained CSV
  • One or more outputs — single output to copy/convert (e.g. change delimiter), or many to split
  • Configurable delimiter — optional -delimiter for semicolon- or tab-separated files
  • Split into N parts — use -n N -o <dir> to create part1.csvpartN.csv in a directory
  • Streaming — processes row-by-row; constant memory even for very large files
  • Standard library only — no external dependencies
  • Single binary — easy to install and script

Install

go install github.com/dmitryravilov/splitcsv/cmd/splitcsv@latest

Or build from source:

git clone https://github.com/dmitryravilov/splitcsv.git
cd splitcsv
go build -o splitcsv ./cmd/splitcsv

Usage

Explicit output files:

splitcsv [-delimiter c] <input.csv> <out1.csv> [out2.csv ...]

Split into N parts (outputs go to a directory):

splitcsv -n N -o <output_dir> [-delimiter c] <input.csv>
Argument / flag Description
input.csv Source CSV (comma-separated by default)
out1.csv One or more output files (header in each; rows distributed round-robin)
-delimiter Optional; single character (e.g. ; or tab \t) for non-comma CSVs
-n Number of parts; creates part1.csvpartN.csv in the directory given by -o
-o Output directory for -n mode (created if it does not exist)
Examples
# Split into three parts (explicit filenames)
splitcsv data.csv part1.csv part2.csv part3.csv

# Split into five parts in a directory
splitcsv -n 5 -o ./chunks data.csv

# Single output (copy with header)
splitcsv data.csv single.csv

# Semicolon-delimited input and output
splitcsv -delimiter ';' european.csv out1.csv out2.csv

Requirements

Go 1.22 or later.

License

MIT

Directories

Path Synopsis
cmd
splitcsv command
splitcsv splits a CSV file into one or more parts with round-robin distribution.
splitcsv splits a CSV file into one or more parts with round-robin distribution.
pkg
splitter
Package splitter splits CSV files into one or more parts with round-robin distribution.
Package splitter splits CSV files into one or more parts with round-robin distribution.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL