Skip Menu |

This queue is for tickets about the Text-CSV CPAN distribution.

Report information
The Basics
Id: 42264
Status: resolved
Priority: 0/
Queue: Text-CSV

People
Owner: Nobody in particular
Requestors: patrick.bourdon [...] bigfoot.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Working with data with embedded sep_char and escape_char
Date: Sat, 10 Jan 2009 01:11:00 +0100
To: bug-Text-CSV [...] rt.cpan.org
From: Patrick BOURDON <patrick.bourdon [...] bigfoot.com>
Working with data with embedded sep_char and escape_char

Hello,


I am trying Text::CSV_PP working with data with embedded sep_char and escape_char.

Note that French sep_char is ';'.


I present hereafter a simple and complete small piece of code including the problem I encountered.

I am unclear about the fact it is a bug or a misusage.

Thanks for the module.


My installation:

- Perl: Active Perl 5.10.0 Build 1004

- OS: Windows XP

- Module: Text-CSV 1.10 (31/10/2008)


Patrick Bourdon - Paris - France


----------------------------------------------------


{

   use Text::CSV_PP();

   my $csv = Text::CSV_PP->new ({

      sep_char            => ";",

      always_quote        => 1,

      binary              => 1,

      allow_whitespace    => 1,

      verbatim            => 1,

   });


   # First test:

   {

      my $line = '20/10/2008;Le LHC;chaines;Le LHC;"Le des ""hadrons"" au CNRS ; Michel CNRS/INP2P3"';

      my $status = $csv->parse ($line);


      # CORRECT: I got the expected result (dump):

      #

      #  $csv->fields() = [

      #                   '20/10/2008',

      #                   'Le LHC',

      #                   'chaines',

      #                   'Le LHC',

      #                   'Le des "hadrons" au CNRS ; Michel CNRS/INP2P3'

      #                 ];

      #

   }


   # Second test:

   {

      use IO::File();

      my $file = 'bug1.csv';

      # bug1.csv includes the same text in first line together with a second line is empty

      #   Line 1: 20/10/2008;Le LHC;chaines;Le LHC;"Le des ""hadrons"" au CNRS ; Michel CNRS/INP2P3"

      #   Line 2:


      my $fh = IO::File->new("<$file") or die("open(<$file) impossible: ($!)!");

      my $fields = $csv->getline ($fh);

     

      # I got the following ERROR:

      #

      # $csv->error_diag () = [

      #    2027,

      #    'EIQ - Quoted field not terminated',

      #    56

      #  ];

      # $csv->error_input() = '20/10/2008;Le LHC;chaines;Le LHC;"Le des ""hadrons"" au CNRS ; Michel CNRS/INP2P3"

      #';

      # $csv->fields() = [ undef ];

   }

}


Subject: Re: [rt.cpan.org #42264] Working with data with embedded sep_char and escape_char
Date: Sat, 10 Jan 2009 19:59:00 +0100
To: Bugs in Text-CSV via RT <bug-Text-CSV [...] rt.cpan.org>
From: Patrick BOURDON <patrick.bourdon [...] bigfoot.com>
Hello, You can reject and close this ticket. Actually the solution is "NOT TO USE" the "verbatim" option. I misunderstood the following sentence about verbatim and from the documentation : "The basic thought behind this is to tell the parser that the normally special characters newline (NL) and Carriage Return (CR) will not be special when this flag is set, and be dealt with as being ordinary binary characters. This will ease working with data with embedded newlines." I understood it was the only way working with data with embedded newlines, which is not ! ... and have side effects... So I suggest some documentation improve Thank you for this great module. Patrick.