Skip to content

Instantly share code, notes, and snippets.

@wboykinm
Last active August 29, 2015 14:12
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 wboykinm/d269ba1695fb0676e04a to your computer and use it in GitHub Desktop.
Save wboykinm/d269ba1695fb0676e04a to your computer and use it in GitHub Desktop.
Split a csv including header into x discrete CSVs
# replace 'FILE.csv' w/ desired split file
# set 'split -l n' as number of rows per new file
tail -n +2 FILE.csv | split -l 100000 - split_
for file in split_*
do
head -n 1 FILE.csv > tmp_file
cat $file >> tmp_file
mv -f tmp_file $file
done
# via Martin Dinov: http://stackoverflow.com/a/20721203/1676407
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment