Last active
June 5, 2018 18:09
-
-
Save biancalpadilla/5314bcb27cf588dbca30efaa1d99c61d to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# You can convert any csv file into a txt file by changing the extension to .txt | |
# Look for a file called file.txt | |
FILE=$(ls -1 | grep file.txt) | |
NAME=${FILE%%.txt} | |
# Save the first line in the file as your header | |
head -1 $FILE > header.txt | |
# Save the rest of file (line 2 and on) as your data file | |
tail -n +2 $FILE > data.txt | |
# Split data at every X number of lines | |
split -l 14500 data.txt | |
# Iterate over each split file | |
for a in x?? | |
do | |
# Add the header to each new file | |
cat header.txt $a > $NAME.$a.txt | |
done | |
# Remove the data file used to split |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment