Last active
August 29, 2015 14:12
-
-
Save wboykinm/d269ba1695fb0676e04a to your computer and use it in GitHub Desktop.
Split a csv including header into x discrete CSVs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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