in reply to Efficiency issue when reading large CSV files

Do you have Text::CSV_XS installed?

BTW, what have you done with <code> tags?

Replies are listed 'Best First'.
Re^2: Efficiency issue when reading large CSV files
by ikegami (Patriarch) on Jun 25, 2009 at 18:28 UTC
    More precisely,
    • Make sure you are using Text::CSV version 1 or greater

      # Use Text::CSV_XS if it's available or the # slower Pure Perl implementation otherwise. use Text::CSV 1.000; ... my $csv_reader = Text::CSV->new(); ...

      and make sure you have Text::CSV_XS installed.

      >perl -e"use Text::CSV_XS"
    • Or just use Text::CSV_XS directly.

      use Text::CSV_XS; ... my $csv_reader = Text::CSV_XS->new(); ...

    The XS version is 50x faster than the Pure Perl implementation according to the author. Both of the above methods will use the XS version.

Re^2: Efficiency issue when reading large CSV files
by Takuan Soho (Acolyte) on Jun 25, 2009 at 18:36 UTC
    I don't have Text::CSV_XS installed, but I'll install it locally and see if it works better.

    Sorry for the format. This is the first time I post and I am still unsure how everything works. The "preview" did not show any formating between the tags, so I included other tags inside the code. I will edit the node.

Re^2: Efficiency issue when reading large CSV files
by ikegami (Patriarch) on Jun 25, 2009 at 18:29 UTC
    More precisely,
    • Make sure you are using Text::CSV version 1 or greater

      # Use Text::CSV_XS if it's available or the # slower Pure Perl implementation otherwise. use Text::CSV 1.000; ... my $csv_reader = Text::CSV->new(); ...

      and make sure you have Text::CSV_XS installed.

      >perl -e"use Text::CSV_XS"
    • Or just use Text::CSV_XS directly.

      use Text::CSV_XS; ... my $csv_reader = Text::CSV_XS->new(); ...

    The XS version is 50x faster than the Pure Perl implementation according to the author. Both of the above methods will use the XS version.