in reply to Re: Perl script help to convert .txt file to .csv
in thread Perl script help to convert .txt file to .csv
Yes you are correct, my mistake
By the way, thanks for the code!
It works great, here is the complete version that reads from and writes to files.use strict; use warnings; print "\n Running script for Jiggs \n"; my $infile = "foot.txt"; open my $in, "<", $infile or die $!; open my $out, ">", "foot1.txt" or die $!; my $line; while ( <$in> ) { chomp; s/length=//; s/xy=//g; s/region=//g; s/run=//g; tr/ /,/s; if ( /^>/ ) { print $out "$line\n" if $line; $line = $_; } else { $line .= $_; } } print $out "$line\n"; close $in; close $out; print "\n Done!\n";
Many thanks to all the responses, I learned so much today: Using RegEx's and substitution, file handling, split function, and joining arrays!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Perl script help to convert .txt file to .csv
by littlemonk (Sexton) on Jan 06, 2014 at 13:48 UTC | |
|
Re^3: Perl script help to convert .txt file to .csv
by ssrao40 (Initiate) on Oct 26, 2014 at 16:08 UTC |