Re:Understanding Awk
by sk5t on Thursday September 30, 2021 @02:24PM
(#28709436)
'miller' and 'xsv' are pretty good tools for wrangling CSV.
(And regexp is kind of a terrible tool for it, too many edge cases.)
[ Parent
| on HN ]
Yeah, I don't want to have to write a CSV library each time, that's what I'm trying to get at.
I just end up using Python/Perl but I do have a soft spot for awk so it would be cool if good support was built-in.
Who's writing a library? Just use xsv or miller to extract the bits you want from the CSV, change the delimiter or escapes to something more convenient, etc., then feed that to awk or other CSV-unaware text processors.
I was agreeing with your point about regexes, that it's good to avoid trying to deal with all the corner cases yourself when you're just trying to write a small script.
Ah, understood! CSV is funny, it seems like a more trivial thing than it really is, and its human readability sort of invites broken approaches in a way that something like Parquet would not.
XML is somewhere in the middle--I've seen some horrible abuses of CDATA sections way back when--but at least there are accepted ways to prove what's invalid.