in reply to Re^2: CSV_XS ERROR: 2027 - EIQ - Quoted field not terminated @ pos 408
in thread CSV_XS ERROR: 2027 - EIQ - Quoted field not terminated @ pos 408

I had also changed to
my $csv = Text::CSV_XS->new ({ binary => 1, auto_diag => 1 }) or die "Cannot use CSV: ".Text::CSV->error_diag ();
Thanks
  • Comment on Re^3: CSV_XS ERROR: 2027 - EIQ - Quoted field not terminated @ pos 408
  • Download Code

Replies are listed 'Best First'.
Re^4: CSV_XS ERROR: 2027 - EIQ - Quoted field not terminated @ pos 408
by Anonymous Monk on May 22, 2010 at 15:51 UTC
    graff suggested how I can get the offending data. Found it! I got it down to 2 lines.
    "vv1","vv2","vv3","vv4","vv5","vv6","vv7","vv8","vv9","vv10","vv11" 251,"a"," Hardware .","Hardware ."," Hardware ","d",,,,,

    Please see if it gives you the error below, too.
    C:\temp>a01.pl There are 1 rows # CSV_XS ERROR: 2027 - EIQ - Quoted field not terminated @ pos 44 2027EIQ - Quoted field not terminated44 at ./csv2xls line 132, <> line + 1.
      Based on the sample data you showed, it looks like the error is right after "vv11" -- here's how it looks, one character at a time (which is how Text::CSV has to look at it):
      " # start of quoted field v v 1 1 " # unescaped quote must mean end of quoted field \n # if this is really in the data (not just the way you pasted into +the post) # then this may be the error right here -- it should be a comma 2 # and if the line-break wasn't the error, then this is 5 1
      The point is that either the quote after vv11 must be escaped or removed, or else there must be a comma after it.

      I still don't understand how the presence/absence of or next in the logic has anything to do with whether this error gets detected. Good luck with that.

      When I copy-paste that data, I get:

      $ cat !$ cat PM-841123.csv "vv1","vv2","vv3","vv4","vv5","vv6","vv7","vv8","vv9","vv10","vv11" 251,"a"," Hardware .","Hardware ."," Hardware ","d",,,,, $ csv-check PM-841123.csv Checked PM-841123.csv with csv-check 1.4 using Text::CSV_XS 0.73 OK: rows: 2, columns: 11 sep = <,>, quo = <">, bin = <1>, eol = <"\n"> $

      You will need the binary => 1, as your data has embedded newlines.


      Enjoy, Have FUN! H.Merijn