5 ms·
Using Awk with CSV Files
- version_five 5y agoIf I have a csv that I know has occasional quotes text with commas in it, I usually first just pass it though a script to substitute quoted commas for something else (either nothing or a pipe symbol, e.g.) - you can do this in a one liner with awk itself using " as a field separator and substituting commas in even fields. Two key lessons I've learned are always confirm that NF is equal to the same value for all rows before you do anything else, and if you have anything more complex than quoted commas (e.g. newlines), don't use awk.