4 ms·
I often use csvquote [1] whenever I need to process CSV with a command-line tool that doesn't support it. For example: csvquote test.csv | awk '{print $1,
by jeroenjanssens 4y ago
I often use csvquote [1] whenever I need to process CSV with a command-line tool that doesn't support it. For example:
csvquote test.csv | awk '{print $1, $2}' | csvquote -u
[1] https://github.com/dbro/csvquote https://github.com/dbro/csvquote
- throwawayboise 4y agoYep, was going to post the same if someone hadn't already. This is the unix way. Small tools with narrow focus, strung together in pipelines.
- sophacles 4y agoawk is a tool for handling records in text. csv is a textual format for records. I'd argue that needing a different tool for handling records in text so that you can pass it to a tool for handling records in text is a bit too far.
- jcelerier 4y agoah yes, awk's famously narrow focus, covering things such as networking (https://www.gnu.org/software/gawk/manual/html_node/TCP_002fIP-Networking.html https://www.gnu.org/software/gawk/manual/html_node/TCP_002fI...) or video games (https://github.com/mikkun/AWKTC https://github.com/mikkun/AWKTC). What do you mean your blog isn't served by awk (https://www.gnu.org/software/gawk/manual/gawkinet/html_node/Primitive-Service.html#Primitive-Service https://www.gnu.org/software/gawk/manual/gawkinet/html_node/...) as a VRML world (https://www.gnu.org/software/gawk/manual/gawkinet/html_node/MAZE.html#MAZE https://www.gnu.org/software/gawk/manual/gawkinet/html_node/...) ?
- MonkeyClub 4y ago>> This is the unix way. Small tools with narrow focus, strung together in pipelines. > ah yes, awk's famously narrow focus, [...] "GNU's Not Unix"
- jcelerier 4y agoAnd GNU is what most people rush for installing on macOS and Windows which says a lot about the actual needs of people Vs the supposed benefits of Unix purism
- dev_tty01 4y agoI think getting awk to recognize that a field separator within a quoted string should be ignored is a great addition. This is not inconsistent with the "unix way." Many, many unix tools recognize that a quoted string should be treated as a separate entity. The more unix-like approach would have been to force users to remove quotes if they want awk to split strings based on field separators within quotes. In hindsight, I'm surprised the quote respecting option wasn't added a long time ago.
- kazinator 4y agoThe article mentions a different such a filter called "csvquote", written in Go: https://github.com/adamgordonbell/csvquote https://github.com/adamgordonbell/csvquote The History section of the readme explains that they are historically related.