My goal is to retrieve the last two rows of a csv file and do a calculation on the unix timestamp..the idea is to get a % OnTime and print the percentage of that time. The csv example rows are as follows:
sequence,timestamp,received,sent,status
1,997891093,,Sent^M
2,997891093,,Sent^M
1,997891394,,Sent^M
3,997891394,,Sent^M
1,997891694,,Sent^M
4,997891694,,Sent^M
1,997897224,,Sent^M
5,997897224,,Sent^M
1,997897546,,Sent^M
6,997897546,,Sent^M
1,997897847,,Sent^M
7,997897847,,Sent^M
1,997898147,,Sent^M
8,997898147,,Sent^M
1,997898448,,Sent^M
9,997898448,,Sent^M
1,997898749,,Sent^M
10,997898749,,Sent^M
11,997899354,,Sent^M
12,997899654,,Sent^M
13,997899955,,Sent^M
14,997900256,,Sent^M
15,997900556,,Sent^M
16,997900860,,Sent^M
17,997901160,,Sent^M
18,997901462,,Sent^M
19,997901763,,Sent^M
20,997902064,,Sent^M
21,997902366,,Sent^M
22,997902667,,Sent^M
23,997902968,,Sent^M
I want to get the percentage of time taken between the last two unix timestamps in the last two rows and print that percentage as follows:
97.040%
If anything is unclear, please let me know as I am happy to answer any questions.
Thanks!
qball~"I have node idea?!"
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.