The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Richard Tobin <richard@inf.ed.ac.uk>
To: tuhs@tuhs.org
Subject: [TUHS] Awk for CSV files
Date: Sun, 13 Oct 2019 14:53:44 +0100 (BST)	[thread overview]
Message-ID: <20191013135344.E0F4C292AD4E@macaroni.inf.ed.ac.uk> (raw)
In-Reply-To: Larry McVoy's message of Thu, 10 Oct 2019 19:56:54 -0700

I was reminded of this by Larry's comment:

> I miss Brian on this list.  I've interacted with him over the years, the
> one I remember the most was I was trying to do an awk like interface to a
> key/value "database".

Recently I've had to deal with a lot of data in CSV
(comma-separated-value) format.  Awk is *almost* prefect for this, but
of course doesn't handle the quoting of fields that contain commas.
One can usually work around it by finding a character that doesn't
occur in the data and converting the CSV file to use that as the
separator, but it's not ideal.

Awk's input could easily be modified to handle CSV files, but output
would be a bit more difficult, because you don't specify field
boundaries explicitly on output.  One possibility would be a printf()
format specifier that takes a field and quotes it appropriately.

-- Richard

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


             reply	other threads:[~2019-10-13 14:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-13 13:53 Richard Tobin [this message]
2019-10-13 14:57 ` arnold
2019-10-13 18:46 ` William Corcoran
2019-10-13 19:36   ` Henry Bent
2019-10-13 22:30     ` William Corcoran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191013135344.E0F4C292AD4E@macaroni.inf.ed.ac.uk \
    --to=richard@inf.ed.ac.uk \
    --cc=tuhs@tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).