the odd number of quotes works great on files that have quotes.
I always seem to get stuck with files that aren't quoted, just commas and
have to count fields (if there are always the same number of fields)
George Gallen
Senior Programmer/Analyst
Accounting/Data Division
[email protected]
ph:856.848.9005 Ext 220
The Wyanoke Group
http://www.wyanokegroup.com
________________________________________
From: [email protected]
[[email protected]] On Behalf Of Wols Lists
[[email protected]]
Sent: Thursday, May 26, 2011 11:01 AM
To: [email protected]
Subject: Re: [U2] [UD] Extract a line with a CR and/or LF character in it.
On 26/05/11 13:26, Rex Gozar wrote:
> For any CSV processing, you must process character by character. Use
> OSBREAD to get a block of characters and start parsing. Strings like
> 1,ABC,"2"" adapter",, can only be correctly parsed by looking at each
> character and applying the simple CSV rules. Using CONVERT statements
> only makes the process more complex and inaccurate.
IF you can handle the entire file as one string in memory, try using
MATPARSE on it! You'll need the two-dimensional, multi-delimiter version
but it could be very effective - look for comma, quote and newline.
Actually, you don't need the entire file, just read it line by line. If
it's got an odd number of quotes you know it's incomplete so you can
read and concatenate the next line, then process the line when it's
complete.
MATPARSE is one of my war stories :-) A supervisor wrote a parser that
was some five pages of printout, iirc. And it was buggy. I looked at it,
used MATPARSE, and rewrote it in about ten lines!
Cheers,
Wol
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users