zsh-users
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Peter Stephenson <p.w.stephenson@ntlworld.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Parsing CVS files
Date: Sun, 3 Feb 2019 05:19:08 +0100	[thread overview]
Message-ID: <CAKc7PVBrpQGYQbF02XUyZKbKjTo0SjM78ykkJ=yC9k1D+yusiQ@mail.gmail.com> (raw)
In-Reply-To: <157d7b5d59005133ae4722f5c452db6aa0078547.camel@ntlworld.com>

On Sat, 2 Feb 2019 at 21:27, Peter Stephenson
> Also, if you want to keep empty fields, you'll need the final result
> to use "${(@}this}".  Probably easiest to assign to an array as otherwise
> the quotes will affect the substitution.

I've had to use "(@)" for every segment, i.e.:

% line='abc,"efg, hehe,yeah",c,,d'
% print -rl "${(@)${(@)${(@)${(z)${${line// /\\ }//,/, }}%%,}//, /,}//\\ / }"
abc
"efg, hehe,yeah"
c

d

And with a random "(@)" missing:
% print -rl "${(@)${${(@)${(z)${${line// /\\ }//,/, }}%%,}//, /,}//\\ / }"
abc "efg, hehe,yeah" c  d


-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

  reply	other threads:[~2019-02-03  4:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-02 18:59 Dominik Vogt
2019-02-02 20:14 ` Peter Stephenson
2019-02-03  4:19   ` Sebastian Gniazdowski [this message]
2019-02-05 21:30     ` Dominik Vogt

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='CAKc7PVBrpQGYQbF02XUyZKbKjTo0SjM78ykkJ=yC9k1D+yusiQ@mail.gmail.com' \
    --to=sgniazdowski@gmail.com \
    --cc=p.w.stephenson@ntlworld.com \
    --cc=zsh-users@zsh.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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).