in reply to Converting CSV to tab-delimited
And you're sure that M$ doesn't export embedded new-lines, carriage-returns or other binary or special characters?
There is a very good reason for Text::CSV (and the undelying Text::CSV_XS and Text::CSV_PP) modules to be around, and installing isn't that hard.
cpan Text::CSVuse strict; use warnings; my $if = shift; my ($of = $if) =~ s/\.csv$/.tab/ or die "usage: csv2tab file.csv"; open my $fh_i, "<", $if or die "$if: $!"; open my $fh_o, ">", $of or die "$of: $!"; my $csv = Text::CSV->new ({ binary => 1 }); my $tsv = Text::CSV->new ({ binary => 1, sep_char => "\t" }); while (my $row = $csv->getline ($fh_i)) { $tsv->print ($fh_o, $row); } close $fh_i or die "$if: $!"; close $fh_o or die "$of: $!"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Converting CSV to tab-delimited
by Tux (Canon) on Apr 14, 2008 at 14:35 UTC | |
|
Re^2: Converting CSV to tab-delimited
by ambrus (Abbot) on Apr 15, 2008 at 14:49 UTC | |
|
Re^2: Converting CSV to tab-delimited
by PhilHibbs (Hermit) on Apr 14, 2008 at 14:22 UTC | |
by Erez (Priest) on Apr 14, 2008 at 17:45 UTC | |
by PhilHibbs (Hermit) on Jun 13, 2008 at 14:45 UTC | |
by Anonymous Monk on Mar 16, 2009 at 22:40 UTC | |
by Anonymous Monk on Mar 18, 2009 at 15:22 UTC |