Skip to content

Instantly share code, notes, and snippets.

@groggu
Created August 17, 2015 14:28
Show Gist options
  • Save groggu/d804e149943d73f8c56a to your computer and use it in GitHub Desktop.
Save groggu/d804e149943d73f8c56a to your computer and use it in GitHub Desktop.
Great script to split up large CSV files into parts. Change the term "filename" below to be the csv file name and change the 25000 to be the number of lines in each split file.
tail -n +2 filename.csv | split -l 25000 - filename_
for file in filename_*
do
head -n 1 filename.csv > tmp_file
cat $file >> tmp_file
mv -f tmp_file $file.csv
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment