ybiC has asked for the wisdom of the Perl Monks concerning the following question:
What I need to do goes something like this (in english):
Read the first and second lines
deltaTime2 = epochSec2 - epochSec1
Bps2 = (ifInOctets2 + ifOutOctets2)/deltaTime2
Read the second and third lines
deltaTime3 = epochSec3 - epochSec2
Bps3 = (ifInOctets3 + ifOutOctets3)/deltaTime3
Read the third and fourth lines
deltaTime4 = epochSec4 - epochSec3
Bps3 = (ifInOctets4 + ifOutOctets4)/deltaTime4
Lather, rinse, repeat...
In a past life, I'd have used Excel for the calculations {oh, the shame} but now I'd *really* like to do this in a Perlish manner. Doing the simple arithmetic in Perl is easy. I imagine the control code might involve split() and a LoL, but am quite unclear on where to start. Any clueful monks care to point me in a good direction?
cheers,
Don
striving toward Perl Adept
(it's pronounced "why-bick")
Collected data csv:
date,time,epochSec,device,ifIndex,ifInOctets,ifOutOctets, 2001-08-10,18:15:00,997485300,boston,141,1916238333,2743654663, 2001-08-10,18:18:12,997485492,boston,141,1917535505,2744657633, 2001-08-10,18:21:23,997485683,boston,141,1919320447,2747461877, 2001-08-10,18:24:34,997485874,boston,141,1921869420,2748722088, 2001-08-10,18:27:46,997486066,boston,141,1925884600,2764661750, 2001-08-10,18:30:57,997486257,boston,141,1929925399,2766849525, ...
Desired output csv:
date,time,,device,ifIndex,Bps, 2001-08-10,18:15:00,boston,141,, 2001-08-10,18:18:12,boston,141,11649, 2001-08-10,18:21:23,boston,141,24969, ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: control+data structures for multi-line math on csv
by tachyon (Chancellor) on Aug 12, 2001 at 03:06 UTC | |
|
Re: control+data structures for multi-line math on csv
by HamNRye (Monk) on Aug 12, 2001 at 02:59 UTC |