Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • First, there's not really a "standard" for CSV. It really means whatever someone wants to throw at you. I had a project last year where multiple business partners would send me "CSV" data, and no two were the same. Some quoted every field. Some only quoted fields that needed it. Some escaped double quotes by doubling them. Some used backslashes. It was a mess.

    Second, don't use Text::CSV. Use Text::CSV_XS []. It's got far more parameters for your tuning enjoyment.



    • I'm pretty sure Text::CSV_XS is the successor to Text::CSV. It's always a good idea to search CPAN [] and look for more recent modules.

      For even more enjoyment, see if you can make use of DBD::CSV.

      J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
      • DBD::CSV was my first choice, however the file we are being sent contains additional record types, which include 1 or more comment records (a ' as the first character) and 1 header record (a # as the first character).

        Plus it was easier to parse the file directly rather than store it locally, parse it, then delete it.