in reply to issue with LF & CRLF

You don't show the value of $csv_setup, but it needs to include binary => 1, also make sure that $/ = "\r\n"; before you open the feed. That should be enough.

Parse::CSV uses Text::CSV_XS as the underlying parser. So you can look at the documentation there for which parameters are available to you.

Replies are listed 'Best First'.
Re^2: issue with LF & CRLF
by nafri (Initiate) on Aug 06, 2013 at 22:57 UTC
    hi thanks for replying binary => 1 is included.. where do i exactly include. $/ = "\r\n"; i added it before if ($fh->open($feed)) { but it makes no difference

      If you create an example file that contains one good record, and one problematic record, then you'll have a test case that is easier to Dump and share here. Below is a little example that works here and shows an embedded newline being handled correctly by Parse::CSV:

      use Parse::CSV; use Data::Dump 'pp'; my $fh = new IO::File('failing.csv', 'r'); my $fail = do { local $/; <$fh> }; pp $fail; # Print input $fh->seek(0,0); $/ = "\r\n"; my $parser = Parse::CSV->new( handle => $fh, csv_attr => { binary => 1 }, ); print pp $_ while $_ = $parser->fetch; # Print output
      Which prints:
      "a,b,c,d,e,f,g\r\na,b,c,\"kkkk\n\",d,e,f,g\r\n" ["a" .. "g"]["a", "b", "c", "kkkk\n", "d" .. "g"]