Created
December 1, 2017 17:48
-
-
Save framundo/99ebb2a7caa38f6612c78b8aaf24d81b to your computer and use it in GitHub Desktop.
CSV Sanitizer
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 | |
iconv -f ISO-8859-1 -t utf-8 $1 > utf8.csv | |
perl -pi -e 's/\r\n|\n|\r/\n/g' utf8.csv # Convert to UNIX | |
sed -e 's/,/\./g' -e 's/"/\\"/g' -e 's/;/","/g' -e 's/$/"/' -e 's/^/"/' utf8.csv > out.csv | |
gawk -F',' -v OFS=',' '{NF=6}1' out.csv > padded.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment