Last Updated: February 25, 2016
·
4.317K
· datasaur

Simple quote-comma CSV parsing in Awk

gawk -vFPAT='[^,]*|"[^"]*"' '{print $1,$2,$3}'

Requires GNU awk 4+, but eliminates the need for a specialized CSV library to handle quoted fields that contain delimiters.

http://www.gnu.org/software/gawk/manual/html_node/Splitting-By-Content.html

Credit for pointing me to this approach goes to: http://stackoverflow.com/a/17287068/75386