From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from minnie.tuhs.org (minnie.tuhs.org [45.79.103.53]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id ccd1d876 for ; Sun, 13 Oct 2019 14:58:54 +0000 (UTC) Received: by minnie.tuhs.org (Postfix, from userid 112) id DDDAB9BCC1; Mon, 14 Oct 2019 00:58:52 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 58213946B9; Mon, 14 Oct 2019 00:58:36 +1000 (AEST) Received: by minnie.tuhs.org (Postfix, from userid 112) id 1592A946B9; Mon, 14 Oct 2019 00:58:34 +1000 (AEST) Received: from freefriends.org (freefriends.org [96.88.95.60]) by minnie.tuhs.org (Postfix) with ESMTPS id 5FBD893DBB for ; Mon, 14 Oct 2019 00:58:33 +1000 (AEST) X-Envelope-From: arnold@skeeve.com Received: from freefriends.org (freefriends.org [96.88.95.60]) by freefriends.org (8.14.7/8.14.7) with ESMTP id x9DEvVQ3026546 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 13 Oct 2019 08:57:32 -0600 Received: (from arnold@localhost) by freefriends.org (8.14.7/8.14.7/Submit) id x9DEvVGa026545; Sun, 13 Oct 2019 08:57:31 -0600 From: arnold@skeeve.com Message-Id: <201910131457.x9DEvVGa026545@freefriends.org> X-Authentication-Warning: frenzy.freefriends.org: arnold set sender to arnold@skeeve.com using -f Date: Sun, 13 Oct 2019 08:57:31 -0600 To: tuhs@tuhs.org, richard@inf.ed.ac.uk References: <20191013135344.E0F4C292AD4E@macaroni.inf.ed.ac.uk> In-Reply-To: <20191013135344.E0F4C292AD4E@macaroni.inf.ed.ac.uk> User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [TUHS] Awk for CSV files X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" Awk and csv isn't new. Googling 'awk csv' gets you a bunch of results. There is also the 'csv' dynamically loadable extension for gawk to be found in the gawkextlib project. Contact me off-list if you want more details. Thanks, Arnold Richard Tobin wrote: > 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.