#!usr/bin/perl
my $newfile = 'cleaned.csv';
open(my $newfh, '>', $newfile) or die "Can't read file '$newfile' [$!]\n";
my $file = 'original.csv';
my @data;
open(my $fh, '<', $file) or die "Can't read file '$file' [$!]\n";
while (my $line = <$fh>) {
chomp $line;
my @fields = split(/,/, $line);
if ($fields[4] eq "Control Line"){
$line2=<$fh>; #second line
$line3=<$fh>; #third line
print $newfh "$line\n";
print $newfh "$line2";
print $newfh "$line3";
}else{
print "$line\n";
}
}
close ($fh);
close ($newfh);
Like this:
Like Loading...
Related
Recent Comments