Created
September 17, 2013 08:47
-
-
Save geoffgarside/6591770 to your computer and use it in GitHub Desktop.
Convert a semicolon separated values file into CSV with proper escaping of commas. Assumes theres are no double quotes in the file already.
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
awk '{ end=split($0,a,";"); result = a[1]; for(i = 2; i <= end; i++) { if (index(a[i], ",")) { a[i] = "\"" a[i] "\""; } result = result "," a[i]; } print result }' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment