awk Useful one-liners - calculating average from a CSV etc Robust processing tabular data (CSV et al.)


Example

Processing tabular data with awk is very easy, provided that the input is correctly formatted. Most software producing tabular data use specific features of this family of formats, and awk programs processing tabular data are often specific to a data produced by a specific software. If a more generic or robust solution is required, most popular languages provide libraries accommodating with a lot of features found in tabular data:

  • optional column names on the first line
  • mixture of quoted and unquoted column values
  • various delimiters
  • localised formats for floating numbers

While it definitely possible to handle all these features cleanly and generically with awk this is probably not worth the effort.