in reply to Re^3: Text Extraction
in thread Text Extraction
Haven't pinned down why the STOCK NO is showing up twice. Just wanted to update you. UPDATE: Now have it removing the first STOCK NO in the final output and print format to a quoted .csv file:G0001,G0001,2010,GMC,ACADIA,/,33410.00 G0002,G0002,2010,GMC,ACADIA,/,32615.00 G0003,G0003,2010,GMC,ACADIA,/,33010.00 G0004,G0004,2010,GMC,ACADIA,/,32615.00 G0005,G0005,2010,GMC,ACADIA,/,33410.00
Thanks again!!/usr/bin/perl use strict; use warnings; my $file = 'gwfnvi.txt'; open(my $fh, '<', $file) or die "$file: $!"; my $csv; foreach my $line (<$fh>) { chomp($line); next unless($line =~ m/^([^\.]+)\.+\s+(.*)/); if($1 eq 'STOCK NO') { $csv = $3; } $csv .= ",\"$2\""; my $str2 = substr($csv, 1); print "$str2\n" if($1 eq 'LST PRICE'); } close($fh);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Text Extraction
by ig (Vicar) on Jul 23, 2009 at 02:28 UTC | |
by sonicscott9041 (Novice) on Jul 23, 2009 at 02:43 UTC | |
by ig (Vicar) on Jul 23, 2009 at 03:33 UTC | |
by sonicscott9041 (Novice) on Jul 23, 2009 at 18:34 UTC |