Hi All, I don't use perl very often and TEXT::CSV_XS is kicking my ass.
I would use Text::CVS which was working great for me except that it doesn't handle french characters.
I also have to use a different seperator because some field have multiple comma separated characters. This is the data:
374|Mike who|kelticjan|mike@someemail.com|23/2/2012 10:57:32|0|0|Mike| +Clements|90 Street Ave|Halifax|New Brunswick|1t5 7y7|516-555-5555|lol + Transportation Inc.|a||a||||a,b,c,d,e,g,h,i,j,k||a|a|a|a|a,b,c,d,e|I +dle time / miles per gallon|a,b,c||b||a,d,f,g,h|
this is what I am trying to do to parse it and print it out with no separator character.
#!/usr/bin/perl use Text::CSV_XS; my $csv = Text::CSV_XS->new ({ quote_char => '"', escape_char => '"', sep_char => "|", eol => $\, always_quote => 0, quote_space => 1, quote_null => 1, quote_binary => 1, binary => 1, keep_meta_info => 0, allow_loose_quotes => 0, allow_loose_escapes => 0, allow_whitespace => 0, blank_is_undef => 0, empty_is_undef => 0, verbatim => 0, auto_diag => 0, }) or die "Cannot use CSV: ".Text::CSV_XS->error_diag (); open my $FH, "<:encoding(utf8)", "test.csv" or die "test.csv: $!" +; while (my $line = $csv->getline ($FH)){ if ($csv->parse (@$line)) { my @field = $csv->fields; foreach my $col (0 .. $#field) { print $field[$col], "\n" ; } } else { print STDERR "parse () failed on argument: ", $csv->error_input, "\n"; $csv->error_diag (); } }
this is the output:
374
I've tried a bunch of ways and seem to be confused ... I'd appreciate some help.
Thanks Mike
In reply to Re: HELP :: Text::CSV_XS separator character tab
by mlaro
in thread Text::CSV_XS separator character tab
by webchalkboard
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |