Created
July 18, 2023 18:01
-
-
Save azmigueldario/8efcc59e76119a55349cb55f785a9eb1 to your computer and use it in GitHub Desktop.
Split CSV file according to number of lines and keep header
This file contains hidden or 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
LINES=100 | |
INPUT_FILE='PATH/TO/TEXT/CSV' | |
tail -n +2 $INPUT_FILE | split -l $LINES - prefix_ | |
for file in prefix_* | |
do | |
head -n 1 $INPUT_FILE > tmp_file | |
cat $file >> tmp_file | |
mv -f tmp_file $file | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment