Skip to content

Instantly share code, notes, and snippets.

@thomasjpr
Created April 13, 2014 15:24
Show Gist options
  • Select an option

  • Save thomasjpr/10588509 to your computer and use it in GitHub Desktop.

Select an option

Save thomasjpr/10588509 to your computer and use it in GitHub Desktop.

Revisions

  1. thomasjpr created this gist Apr 13, 2014.
    28 changes: 28 additions & 0 deletions pipe-to-comma.pl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    #!/usr/bin/perl

    use File::Basename qw(basename);

    $me = basename ($0);

    if ( $#ARGV < 0 )
    {
    print "Usage : $me <CSV File Name>\n";
    exit;
    }

    my $IN_CSV = shift @ARGV;
    my $OUT_PIPE = $IN_CSV;
    $OUT_PIPE=~s/\.csv/\.txt/g;


    open (OUTPUT, ">$OUT_PIPE") || die "Can not open $OUT_PIPE - $!" ;
    open (INPUT, "<$IN_CSV") || die "Can not open $IN_CSV - $!" ;

    while (<INPUT>)
    {
    $_=~ s/\|/\,/g;
    print OUTPUT $_;
    }

    close INPUT;
    close OUTPUT;