Created
June 3, 2020 15:38
-
-
Save lucassmacedo/2fe35d689e2d832df7d45e9d20163a63 to your computer and use it in GitHub Desktop.
Convert Large CSV File to many files with headers
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
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