I am using the Text::CSV
module to parse lines into various fields from a tab-separated value file.
Examples of special characters in strings are
"CEZARY Å?UKASZEWICZ, PAWEÅ? WIETESKA","BÜRO FÜR"
My code goes as below:
my $file = $ARGV[0] or die "Need to get TSV file on the command line\n";
my $csv = Text::CSV->new({sep_char => "\t"});
open(my $data,'<', $file) or die "Could not open '$file' $!\n";
while (my $line= <$data>) {
if($csv->parse($line)){
my @curr_arr = $csv->fields();
}
} # end of while
close $data;
The above is some of the important parts of my code. The error I get is as follows:
cvs_xs error : 2026 - EIQ - Binary Character inside quoted field, binary off @pos 15
To read a column from csv for this purpose I wrote this script: #!/usr/bin/perl -w use strict; use warnings; use Text::CSV; my$column_separator = qr/,/; my $column_number = "3"; my$file = "/home/Admin/Documents/new (copy).
Parsing a file means reading the data from a file. The file may contain textual data so-called text files, or they may be a spreadsheet.
my $csv = Text::CSV->new({ binary => 1, sep_char => "\t"});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With