for my $filename (@ARGV) {
open my $fh, '<', $filename or die "error: $!";
my $line_number = 0;
my %fields = ( filename => $filename );
while (my $line = <$fh>) {
$line_number++;
if ($line_number == 1) {
$field{field1} = substr $line, 10, 5; # start character 10 (0 based) take 5
}
if ($line_number == 2 {
$field{field2} = substr $line, 30, 5;
}
}
open my $output, '>>', 'output.csv' or die "error: $!";
print $output "$field{filename},$field{field1},$field{field2}$/";
}
A little work and all 100's of your files are in a CSV in the blink of an eye vs hours and hours of trying to figure out regular expressions and macros for some specific editor and doing each file.You are not logged in, either login or create an account to post comments
Or you could just get some Windows implementation (GNUWin32?) of Unix utilities such as cut or awk (a.k.a. gawk) to do the job at the command line.
But if you get as far as having to use awk, you might as well use Perl, Python, Ruby, etc. I understand you're reluctant to program, but this is a very easy task. One simplification I'd recommend is not outputting to CSV as an intermediate step but rather TSV, because Refine, Excel, etc. will read that in fine.
posted by Monsieur Caution at 10:04 AM on January 14 [1 favorite]