Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lucassmacedo/2fe35d689e2d832df7d45e9d20163a63 to your computer and use it in GitHub Desktop.
Save lucassmacedo/2fe35d689e2d832df7d45e9d20163a63 to your computer and use it in GitHub Desktop.
Convert Large CSV File to many files with headers
awk -v l=500000 '(NR==1){header=$0;next}
(NR%l==2) {
close(file);
file=sprintf("%s.%0.5d.csv",FILENAME,++c)
sub(/csv[.]/,"",file)
print header > file
}
{print > file}' empresas.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment