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

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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.



Got any awk Question?