Skip to content

Instantly share code, notes, and snippets.

@anroopak
Last active January 18, 2019 05:55
Show Gist options
  • Save anroopak/e596e6aa250d681f79498bd694510402 to your computer and use it in GitHub Desktop.
Save anroopak/e596e6aa250d681f79498bd694510402 to your computer and use it in GitHub Desktop.
Script to split CSV files to small chunks
# Credit: https://stackoverflow.com/a/53269966/2594980
csvheader=`head -1 bigfile.csv`
split -d -l10000 bigfile.csv smallfile_
find .|grep smallfile_ | xargs sed -i "1s/^/$csvheader\n/"
sed -i '1d' smallfile_00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment