[Chicago-talk] Simple csv text parsing question

Steven Lembark lembark at wrkhors.com
Fri Apr 11 07:44:38 PDT 2008


> So i played with Text::CSV, Text::XS and Text::xSV last night and got
> thoroughly lost :-). each one having its different confusing points..
> each one saying that they support embedded newlines, each without an
> explanation that i understand. If anyone can point me to an example i
> would be in your debt. I have been beating my head against the wall for
> 30 or more hours on this problem..and its making me question basic
> simple little things in perl... which isn't good.
>
> Nothing like a simple problem to humble you :-)

It may be that you have to parse the thing yourself.
Reading in chunks, you can use Text::Balanced to
handle reading over the newlines by slurping the
end-of-text quote. Text::Balanced doesn't care
about newlines at all, just the quotes it trying
to balance. As you chew through the data, use
T::B to suck up a string, otherwise just snag
the next EOL/comma.

Any time you start mixing un-escaped delimiters
into the data you are going to cause severe pain
for yourself. The thing in this case is that it
is not a simple problem!


-- 
Steven Lembark                                            85-09 90th St.
Workhorse Computing                                 Woodhaven, NY, 11421
lembark at wrkhors.com                                      +1 888 359 3508


More information about the Chicago-talk mailing list