Skip to content

Instantly share code, notes, and snippets.

@amosshapira
Created September 25, 2014 02:05
Show Gist options
  • Save amosshapira/c9ba2d62c0372f4eefb4 to your computer and use it in GitHub Desktop.
Save amosshapira/c9ba2d62c0372f4eefb4 to your computer and use it in GitHub Desktop.
Extract double-quoted fields from CSV file using GNU Awk
#!/usr/local/bin/gawk -f
# Taken from http://stackoverflow.com/a/8949920/164137
BEGIN {
FS=","
FPAT="([^,]+)|(\"[^\"]+\")"
}
{
for (i=1;i<=NF;i++)
printf ("[%s] ",$i);
print ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment