perl - Unable to parse csv file using Text::CSV -


i've csv file in format:

"keyword"   "competition"   "global monthly searches"   "local monthly searches (united states)"    "approximate cpc (search) - inr"  "kasperaky support" -0  -0  -0  -0 

the first line column titles.

i've tried of options in text::csv i'm not able extract fields.

here sep_char=>' '

the nearest go first word of first column("kasperaky" only).

i'm creating object way(while trying various settings):

my $csv = text::csv->new ( {      binary => 1 ,     sep_char=>' ',allow_loose_quotes=>0,quote_space=>0,quote_char          => '"',     ,allow_whitespace    =>0, eol=>"\015\012"      } )                   or die "cannot use csv: ".text::csv->error_diag (); 

your csv tab-separated. use following (code tested work against example file):

use strictures; use autodie qw(:all);       # automatic error checking open/close use charnames qw(:full);    # \n named characters use text::csv qw(); $csv = text::csv->new({     auto_diag   => 2,       # automatic error checking csv methods     binary      => 1,     eol         => "\n{cr}\n{lf}",     sep_char    => "\n{tab}", }) or die 'cannot use csv: ' . text::csv->error_diag;  open $fh, '<:encoding(ascii)', 'computer crash.csv'; while (my $row = $csv->getline($fh)) {     ... } close $fh; 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -