csv parse bug...



Hi,

If I have wrongly posted this here instead of reporting this as a
module bug, pl excuse me.

I am facing an odd bug when using parse() function in Text::CSV module.
This is an absolutely textbook use of the function which fails for some
30 records out of ~ 25000 records.

I have checked, and have found a very strange pattern. In one of the
possible fields which will have embedded commas qualified by double
quotes (like "CN=XX ,OU=XX,OU=XX,DC=XX,DC=XX"), if a pattern line "
,OU" appears, the parse fails... which means if there is a space before
the embedded comma in one of the comma seperated fields, the parse
fails.

This is very puzzling. Can someone help explain.

The code where I exit from the code with parse error is pasted below...


##for each ldap record (every $ads_profile in @ads_datalines),
foreach my $ads_profile (@ads_datalines){
#print STDERR "cycling through ldap records\n";
#@temparray =
(DN,sAMAccountName,givenName,sn,telephoneNumber,department,mail)
my @temparray = ();
my $csv = Text::CSV->new;
if ($csv->parse($ads_profile)) {
@temparray = $csv->fields;
} else {
my $err = $csv->error_input;
print "parse() failed on argument: ", $err, " ", $ads_profile,
"\n";
}

......

.



Relevant Pages

  • Re: csv parse bug...
    ... > module bug, pl excuse me. ... > I am facing an odd bug when using parse() function in Text::CSV ... This is an absolutely textbook use of the function which fails ... > possible fields which will have embedded commas qualified by double ...
    (comp.lang.perl.misc)
  • Re: csv parse bug...
    ... > If I have wrongly posted this here instead of reporting this as a ... > module bug, pl excuse me. ... > possible fields which will have embedded commas qualified by double ... >,OU" appears, the parse fails... ...
    (comp.lang.perl.misc)
  • Re: require and the site_ruby directory...
    ... Just Another Victim of the Ambient Morality wrote: ... One way that it is defective is that it can't always parse the links of a page. ... The strange thing is that it works find for some pages but completely fails for others. ... I have yet to run into public Ruby libraries which require you to copy them into the Ruby directory. ...
    (comp.lang.ruby)
  • Reading poorly structured data
    ... Paul Newmans's Own Brand Foods, 123 Main Street, ... Blair, Tony, 1 Downing Street, London, UK ... Any ideas how to parse this using Perl? ... address with embedded commas) in which cases it will parse the ...
    (comp.lang.perl.misc)
  • Re: Text to Date(MM/DD/YY) Conversion
    ... >You should be able to use the CDate function to convert ... If that fails, you can parse the date into the ...
    (microsoft.public.access.conversion)