Created
October 15, 2019 06:59
-
-
Save pureugong/f34ba4da9200b97dd93a683c8cc701b0 to your computer and use it in GitHub Desktop.
how to parse csv with awk, which has "new lines within double quotes"
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
| cat << EOF > /tmp/sample.csv | |
| "one", | |
| "three | |
| four", | |
| "seven" | |
| EOF | |
| gawk -v RS='"' 'NR % 2 == 0 { gsub(/\n/, "") } { printf("%s%s", $0, RT) }' /tmp/sample.csv | awk -F, '{print $1}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment