Documentation ¶
Overview ¶
Command csvsplit splits a .csv into multiple, smaller files.
Resulting files will be saved as 1.csv, 2.csv, etc. in the currect directory, unless the -output flag is used.
Install ¶
Requires Go to be installed first, https://golang.org/doc/install.
$ go get github.com/JeffPaine/csvsplit
Flags ¶
Basic usage: csvsplit -records <number of records> <file>
-records
Number of records per file
-output
Output filename / path (optional)
-headers
Number of header lines in the input file to add to each ouput file (optional, default=0)
Examples ¶
Split file.csv into files with 300 records a piece.
$ csvplit -records 300 file.csv
Accept csv data from stdin.
$ cat file.csv | csvsplit -records 20
Split file.csv into files with 40 records a piece and two header lines (preserved in all files).
$ csvplit -records 40 -headers 2 file.csv
You can use the -output flag to customize the resulting filenames. The below will generate custom_filename-001.csv, custom_filename-002.csv, etc..
$ csvsplit -records 20 -output custom_filename- file.csv
Split file.csv into files with 37 records a piece into the subfolder 'stuff'.
$ csvplit -records 37 -output stuff/ file.csv