[Bio] / Sprout / AttrDBRefresh.pl Repository:
ViewVC logotype

Diff of /Sprout/AttrDBRefresh.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10, Sun Feb 4 13:05:39 2007 UTC revision 1.11, Sun Feb 4 14:05:24 2007 UTC
# Line 209  Line 209 
209          my $ih = Open(undef, "<$fileName");          my $ih = Open(undef, "<$fileName");
210          # Now we open the proposed output file.          # Now we open the proposed output file.
211          my $oh = Open(undef, ">$fileName.fixed");          my $oh = Open(undef, ">$fileName.fixed");
212            # Create a statistics object to track our progress.
213            my $stats = Stats->new('lines', 'trims');
214          Trace("Cleaning $fileName and copying to $fileName.fixed.") if T(2);          Trace("Cleaning $fileName and copying to $fileName.fixed.") if T(2);
215          # Loop through the input file.          # Loop through the input file.
216          while (! eof $ih) {          while (! eof $ih) {
217              # Get the next record in the input file.              # Get the next record in the input file.
218                $stats->Add(lines => 1);
219              my ($id, $key, @values) = Tracer::GetLine($ih);              my ($id, $key, @values) = Tracer::GetLine($ih);
220              # Trim the values.              # Trim the values.
221              map { $_ =~ s/(^\s+)|(\s+$)//g } @values;              for my $value (@values) {
222                    if ($value =~ /(\S.+\S)\s+/) {
223                        $value = $1;
224                        $stats->Add(trims => 1);
225                    }
226                }
227              # Write the result to the output file.              # Write the result to the output file.
228              Tracer::PutLine($oh, [$id, $key, @values]);              Tracer::PutLine($oh, [$id, $key, @values]);
229          }          }
230          # Close the files.          # Close the files.
231          close $ih;          close $ih;
232          close $oh;          close $oh;
233          Trace("$fileName.fixed is now a cleaned backup.") if T(2);          Trace("$fileName.fixed is now a cleaned backup.\n" . $stats->Show()) if T(2);
234      }      }
235      if ($options->{loadKey}) {      if ($options->{loadKey}) {
236          # We want to load the attribute data from the specified file, but          # We want to load the attribute data from the specified file, but

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3