Wednesday, December 13, 2017

Re: pattern for substitution including linefeed and carriage return

Am 12/11/2017 um 11:06 PM schrieb Erhy:
...
>> valid in CSV if enquoted?
>
> It's also odd for me. But the file comes from a banking institution.

Well, then it's not 'odd' but typical. You get something like:
-------------------------------- kind of symbolically:
first some text like title or explanations, then column/field) names
field;names;separated;by semicolon;and;explaining the following lines
data1;data2;data3;data4 blanks OK;OK! OK;more data up to EOL
DATA1;DATA2;;;;" and like an address with quoted multiple lines
Who
Where
City
etc.etc.etc."
or;even;"a first field
with newline";"a
second
field
with
newlines";still in line 3 of data;end of field 6 of logical line 3
---------------------------------------------------------------------
as long as you have e.g. 5 separators (here ';' so 6 fields of data)
and all cases of 'newline in a field' are quoted in double quotes,
this is correct for the so called 'Comma Separated Values'.
(Where 'banking', mostly uses semicolon for the delimiter,
because '.' is often used in fields.

See more at https://tools.ietf.org/html/rfc4180

BUT parsing such input by vim (i.e. 'regexp') seems to me to be
overly complex (or even unworkable?). Number or fields and newlines
are unlimited. So the structure is a lot easier to work with by
'real' CSV Libraries (e.g. in Perl or Python) or spreadsheet programs.
(Or even the simple 'csvtool' on command line in Linux)

Stucki

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: