Skip to content

PostScripton/splinter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Splinter

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.

Installation

go build -o ./bin/splinter ./cmd/splinter

Or install globally:

go install ./cmd/splinter

After 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)/bin

Or call it directly with the full path: $(go env GOPATH)/bin/splinter

Usage

splinter -f <file> -n <row_count> -o <output_directory> [-s <separator>]

Flags

  • -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

Examples

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
splinter

Output File Format

When splitting a file example.csv, the following files will be created:

  • example_1.csv
  • example_2.csv
  • example_3.csv
  • etc.

Each file contains:

  • Original CSV header
  • Specified number of data rows (or fewer for the last file)
  • Preserved column order

Project Structure

splinter/
├── cmd/
│   └── splinter/
│       └── main.go          # Entry point, argument parsing
├── internal/
│   └── splitter/
│       └── splitter.go      # CSV splitting business logic
├── go.mod
└── README.md

Requirements

  • Go 1.21 or higher

Dependencies

The project uses only the Go standard library:

  • flag - for CLI flag handling
  • encoding/csv - for CSV file operations
  • os, path/filepath - for filesystem operations

About

Splinter - CLI utility for splitting CSV files into parts by rows

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors

Languages