Created
February 11, 2021 18:35
-
-
Save codernik/846b5a507735b851c06a63c3b6b088eb to your computer and use it in GitHub Desktop.
Shell script for spliting csv file into multiple parts.
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
#!/bin/bash | |
FILENAME=main.csv | |
HDR=$(head -1 $FILENAME) | |
split -l 1000 $FILENAME xyz | |
n=1 | |
for f in xyz* | |
do | |
if [ $n -gt 1 ]; then | |
echo $HDR > Part${n}.csv | |
fi | |
cat $f >> Part${n}.csv | |
rm $f | |
((n++)) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment