Skip to content

Instantly share code, notes, and snippets.

@mikeatlas
Last active April 1, 2022 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeatlas/316e196f95c73d5d24f3ad4ab95dfc35 to your computer and use it in GitHub Desktop.
Save mikeatlas/316e196f95c73d5d24f3ad4ab95dfc35 to your computer and use it in GitHub Desktop.
some bash shell timesaver for splitting up csv
function split-csv() { 
  fn=${1:0:-4}; 
  fe=${1: -4}; 
  split -d -n $2 ${fn}${fe} ${fn}__part_; 
  for f in ${fn}__part*; do mv $f ${f}${fe}; done; 
};

Usage: split-csv big.csv 2

yields:

big__part_01.csv

big__part_02.csv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment