josephjohn has asked for the wisdom of the Perl Monks concerning the following question:
open DataFile, "Inventory.csv" or die ("Inventory.csv $!"); my @Inventory = <DataFile>; close DataFile; open DataFile, "clients.txt" or die ("clients.txt $!"); while (my $line = <DataFile>) { my @fields = split(/,/, $line); my $username; my @sys; my $beg = 0; my $end = $#Inventory; my $mid = int(($beg+$end)/2); while ($beg <= $end) { @sys = split(/,/,$Inventory[$mid]); if ($fields[3] eq $sys[0]) { $company = $sys[3]; $username = $sys[1]; #remove the matched line from inventory @Inventory = (@Inventory[0..$mid-1],@Inventory[$mid+1..$#I +nventory]); last; } elsif ($fields[3] lt $sys[0]) { $end = $mid - 1; } else { $beg = $mid + 1; } $mid = int(($beg+$end)/2); } push @Data, $fields[3].",".$company.",".$fields[6].",".$fields[7]. +",".$fields[4].",".$fields[11].",".$username.",".$sys[4]; } #processing @Data after this
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Data parsing - takes too long
by Limbic~Region (Chancellor) on Jan 13, 2006 at 18:50 UTC | |
|
Re: Data parsing - takes too long
by ptum (Priest) on Jan 13, 2006 at 18:50 UTC | |
by josephjohn (Acolyte) on Jan 16, 2006 at 09:58 UTC | |
|
Re: Data parsing - takes too long
by glasswalk3r (Friar) on Jan 13, 2006 at 19:18 UTC | |
by salva (Canon) on Jan 14, 2006 at 11:16 UTC | |
|
Re: Data parsing - takes too long
by Fletch (Bishop) on Jan 13, 2006 at 19:00 UTC |