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

Your program flow looks sane, and I cannot tell what is or would be the problem without seeing at least the error message you get. Better would be to also post the lines that cause the error.

You already use error_diag () as it should, but you might consider changing the initiator to new ({ binary => 1, auto_diag => 1 }).

What I also wonder, is why you use the -w flag on the hashbang line and have disabled use strict; and use warnings;.


Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^2: Text::CSV_XS read from line X
by tw (Acolyte) on Jan 04, 2011 at 07:26 UTC

    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

      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?