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

View of /Sprout/ListRelations.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Tue Aug 16 20:33:53 2005 UTC (14 years, 9 months ago) by parrello
Branch: MAIN
Added a utility to generate a CSV file that can be loaded into Excel for use as a database load status spreadsheet.

#!/usr/bin/perl -w

=head1 ListRelations

This script creates a CSV checklist to help in loading an ERDB-style database. It
has two parameters: a database type and an output file name.

C<ListRelations >I<[options]>C< >I<type>C< >I<outputFile>

=over 4

=item type

Database type, which is currently either C<Sprout> or C<SimBlocks>.

=item outputFile

Name of the CSV file to be generated.

=back

The currently-supported command-line options are as follows.

=over 4

=item trace

Numeric trace level. A higher trace level causes more messages to appear. The
default trace level is 2.

=back

=cut

use strict;
use Tracer;
use DocUtils;
use TestUtils;
use Cwd;
use File::Copy;
use File::Path;
use ERDB;
use SimBlocks;
use SFXlate;

# Get the command-line options.
my ($options, @parameters) = Tracer::ParseCommand({ trace => 2 }, @ARGV);
# Set up tracing.
my $traceLevel = $options->{trace};
TSetup("$traceLevel errors Tracer DocUtils ERDB", "TEXT");
# Get the database type.
my $dbType = lc $parameters[0];
# Get the ERDB object.
my $erdb;
if ($dbType eq 'sprout') {
    my $sprout = SFXlate->new_sprout_only();
    $erdb = $sprout->{_erdb};
} elsif ($dbType eq 'simblocks') {
    $erdb = SimBlocks->new();
} else {
    Confess("Invalid database type $parameters[0].");
}
# Open the output file.
Open(\*CSVOUT, ">$parameters[1]");
# Get a list of the tables.
my @tables = $erdb->GetTableNames;
# Print a header.
print CSVOUT "\"FIG RDY\",\"DTX RDY\",\"LOADED\",\"TABLE NAME\"\n";
# Loop through the table names, printing them.
for my $table (@tables) {
    print CSVOUT "\" \",\" \",\" \",\"$table\"\n";
}
# Close the output file.
close CSVOUT;

1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3