Sorry. I didn't mean for that to sound like a job request. I was more concerned with properly describing my needs that I was at formating my request for suggestions.
I have other scripts that calculate averages for these columns, and I will include that code here. I would like to use DBD::CSV on this, but lack the SQL experience to properly script this with out looping over and over in the file.
# Connect to the database, (the directory containing our csv file(
+s))
my $dbh = DBI->connect("DBI:CSV:f_dir=.;csv_eol=\n;");
# Associate our csv file with the table name 'results'
$dbh->{'csv_tables'}->{'results'} = { 'file' => "$CWD/$name"};
my $sth = $dbh->prepare("SELECT * FROM results WHERE 1=0");
$sth->execute;
my @origcols = @{$sth->{NAME}};
my @cols; # = @origcols;
shift @origcols; # Eliminate First Column
foreach ( @origcols ) {
push ( @cols , $_ ) unless /Bandwidth.*|MSTCPLoop.*/ ; # Remove
+ unwanted columns
};
my $avgSQL =
'SELECT '
. join(', ', map { "avg($_) \n" } @cols )
. ' FROM results';
my @avgs = $dbh->selectrow_array($avgSQL);
my %avgsHash;
@avgsHash{ @cols } = @avgs; # uses a hash slice to populate %avgs
+Hash
for ( @cols ) {
(my $changed = $_) =~ s/_/","/;
printf STATS ("\"%s\",%f\n", $changed, $avgsHash{$_});
}
Honestly, I have only made a couple of attempts at this. I'm really stumped on how to format the SQL query. I think that is someone could point me in the direction the SQL query should look like, I'd be able to create it.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|