Sunday, November 30, 2008

Friday, November 28, 2008

Moving Average Perl Script

#!/usr/bin/perl
use strict;
use warnings;
use Text::CSV;

my $csvfile = 'Combined.csv';
my $newfile = 'averaged.csv';


my $csv = Text::CSV->new();

open (CSV, "<", $csvfile) or die "Couldn't open output file: $!";
open (OUT, ">",$newfile) or die "Couldn't open output file: $!";

my $i=0;
my $l=0;
my @time;
my $tave;
my @doppler;
my $dave;
my @hyperfine;
my $have;
my $window=2;


while () {
if ($csv->parse($_)) {
my @columns = $csv->fields();

$time[$i-int($i/$window)*$window]=$columns[0];
$doppler[$i-int($i/$window)*$window]=$columns[1];
$hyperfine[$i-int($i/$window)*$window]=$columns[2];

if($i>=$window){

for($l=0;$l<$window;$l++){

$tave+=$time[$l]/$window;
$dave+=$doppler[$l]/$window;
$have+=$hyperfine[$l]/$window;

}



print OUT "$tave \t\t $dave \t\t $have \n";
$tave=0;
$dave=0;
$have=0;

}
$i++;

} else {
my $err = $csv->error_input;
print "Failed to parse line: $err";
}
}
close CSV; close OUT;

print "\n Moving Average taken over $i lines.\n";

epic sneez

epic sneez: "




funny pictures of cats with captions


epic sneez in 3,2,


maek sur 2 turn ur head tho wen u do sneez.


picture: dunno source, via our lolcat builder. lol caption: Zlol 8


» Recaption This


''''''



"



(Via Lolcats 'n' Funny Pictures - I Can Has Cheezburger?.)

vortex kitteh

vortex kitteh: "




funny pictures of cats with captions


vortex kitteh claims another.


picture: dunno source, via our lolcat builder. lol caption: eternal.dragon


» Recaption This


''''''



"



(Via Lolcats 'n' Funny Pictures - I Can Has Cheezburger?.)

Blog Archive

Twitter Updates