Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7494179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:21:41+00:00 2026-05-29T17:21:41+00:00

I have written a simple perl script to read a line from a .csv

  • 0

I have written a simple perl script to read a line from a .csv file. The code is as per below:

#!/usr/bin/perl

use strict;
use warnings;

use Text::CSV;

my $csv = Text::CSV->new({ binary => 1 });


open my $fh, "<", "testresults.csv" or die "testresults.csv $!";
while ( my $row = $csv->getline( $fh ) ) {
      my @fields = @$row;
}
$csv->eof or $csv->error_diag;
close $fh or die "testresults.csv $!";

And the testresults.csv file looks like this:

Node1,Node2,Node3,Node4,map1,map2,map3,map4,map5,map6,map7,map8,DM,LAT,AVG,product

on the first line followed by the results on each line:

name1,name2,name3,name4,Node1,Node2,Node3,Node4,Node5,Node6,Node7,Node8,0%,
0.002835480002,0.1714008533,4.86003691857886E-04

and so on.

I am getting the following error with my code when I do a ./filename.pl from the command prompt:
CSV_XS ERROR: 2032 – EIF – CR char inside unquoted, not part of EOL @ pos 420

I tried to google for this error but could not fathom much into this error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T17:21:44+00:00Added an answer on May 29, 2026 at 5:21 pm

    It would seem from our conversation in the comments that the error comes of the strings in the input being interlaced with null characters, being made visible by using

    use Data::Dumper;
    $Data::Dumper::Useqq = 1;
    while (<$fh>) {
        print Dumper $_;
    }
    

    A quick hack is to strip the null characters in the input file with something like:

    perl -i.bak -pwe 'tr/\0//d' testresults.csv
    

    NOTE: But as has been pointed out in comments from people more experienced in encoding matters, this can/could/should be solved by decoding your data instead. Just stripping the bad symbols might break your data in subtle ways, and is not an ideal solution.

    I’m sorry, I do not know much about that, but using Text::CSV::Encoded does sound like a good start, like cjm suggested.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a Perl script to read the configuration file and create CGI
how to read the multiple values from XML file using perl script? i have
I have written simple script: #!/bin/bash find . -name *.m4a | while read filename;
I have written a very simple bash script to help me migrate from dev
I have written a very simple WCF service, that worked fine (code below), then
I have a Perl script to convert the XML file below into a hash:
Below, I have written simple code that re-creates problems that have emerged as my
I have written a simple brainfuck interpreter in MATLAB script language. It is fed
I have written a simple jQuery.ajax function which loads a user control from the
I have written a Perl script that runs as a daily crontab job that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.