in reply to Convert CSV file to TAB delimited

Here is short script that will print all the .csv formatted files in your current directory, then prompt you for the file to convert and the name to give the tab delimited file. Finally it will perform the conversion

#!/usr/bin/perl # convert comma seperated file to tab delimited use strict; use warnings; system ("clear"); system ("ls *.csv"); print "\n"; print 'What is the comma seperated file you need to convert? '; chomp (my $csv_file = <> ); print 'What shall I name the new file? '; chomp (my $tabd_file = <> ); system ("< $csv_file tr \",\" \"\t\" > $tabd_file"); exit;

Replies are listed 'Best First'.
Re^2: Convert CSV file to TAB delimited
by choroba (Cardinal) on Nov 06, 2014 at 08:41 UTC
    This doesn't work correctly for commans contained in quotes:
    1,abc,"def,ghi",jkl

    Also, it doesn't work on MS Windows. Calling system for functionality already available in Perl itself isn't needed, anyway. There already are better answers.

    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ