in reply to Re: Text::CSV_XS read from line X
in thread Text::CSV_XS read file from line X

Hi Tux, thanks for the reply

The error I get is: # CSV_XS ERROR: 2034 - EIF - Loose unescaped quote

When trying to read the entire csv file. There is just lines of text in the header, no systematic commas.

Basically I don't need the header lines from the csv file in the array and I can't read the whole file in using CSV_XS because of the error above, otherwise i could just remove them once in an array.

Was just experimenting with the -w, use stict etc. just forgot to adjust before posting, sorry.

regards

Replies are listed 'Best First'.
Re^3: Text::CSV_XS read from line X
by Tux (Canon) on Jan 04, 2011 at 07:51 UTC

    Could it be that your data at that line looks somewhat like

    1,"a",5,"ape " betablocker",16 ^

    In that case, if the data is still valid, you should possibly add { allow_loose_quotes => 1 }, see here about two pages down.


    Enjoy, Have FUN! H.Merijn

      Thanks Tux,

      The entire file is read and pushed in the array if I turn on allow_loose_quotes. Gives me another option! Probably should have picked up on that myself.

      Does allowing loose quoting mean there might be a greater risk of something going astray?

        Not if the data is consistently doing this. It would not be strict CSV policy, but there are a zillion formats that look like but in fact break strict CSV definition. Text::CSV_XS has been stuffed with options to accommodate for all these varieties.


        Enjoy, Have FUN! H.Merijn
Re^3: Text::CSV_XS read from line X
by GrandFather (Saint) on Jan 04, 2011 at 07:29 UTC