Computing.Net > Forums > Unix > weekly total

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

weekly total

Reply to Message Icon

Name: Robert Pearson
Date: April 2, 2003 at 13:12:37 Pacific
OS: solaris
CPU/Ram: e450 / 4gig
Comment:

Okay, I think I am almost done. Just to let you guys know, I have found a lot of things on my own...

I would like to give data totals for a given week from Sunday to Saturday. Most of the questions I asked I had somewhat of a start on before I asked (not necerally anywhere close to the end answer). I am totally clueless on this one.

03/16/2003 10355.2
03/17/2003 10770.9
03/18/2003 9259.4
03/19/2003 8131.2
03/20/2003 8914.6
03/21/2003 10473.9
03/22/2003 12896.2
03/23/2003 11312.6
03/24/2003 11207.6
03/25/2003 9841.2
03/26/2003 8470.0
03/27/2003 10481.5
03/28/2003 12226.4
03/29/2003 15764.8

This is what I want...
Week ending 03/22/2003 70801.4
week ending 03/29/2003 79304.1



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: April 2, 2003 at 19:47:40 Pacific
Reply:

Robert:

Totally brute force:

#!/usr/bin/ksh

awk ' BEGIN { total=0 }
{
total+=$2
if ($1 == "03/22/2003" || $1 == "03/29/2003")
{
printf("Week ending %s is: %.2f\n", $1, total)
total=0
}
} ' data.file
# end awk script

Regards,

Nails


0

Response Number 2
Name: kannan
Date: April 3, 2003 at 04:02:17 Pacific
Reply:

hai,
i read ur question. very interesting programming question. but i can't understand fully. wad my doubt was whether v have to generalise the code, or i have to find sum from 16th to 22nd and 23rd to 29th. plz explain me the question breifly.

byee
kannanvijay


0

Response Number 3
Name: Robert Pearson
Date: April 4, 2003 at 11:25:14 Pacific
Reply:

Yes, I am looking for a sum of the 2nd column.

The script nails gave me works, but it gives a sum for the first one of everything before it. Is there a way to tell it to go back only 7 days?

Is there a way to have it automatically figure out the dates?

Thanks for what you have given me so far.

Robert


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


SED using special charact... Please help! Variables



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: weekly total

Make Money FASTand EASY, TOTALLY LEGAL www.computing.net/answers/unix/make-money-fastand-easy-totally-legal/464.html

Find the day of week using AWK www.computing.net/answers/unix/find-the-day-of-week-using-awk/5243.html

to calculate column total www.computing.net/answers/unix/to-calculate-column-total/3992.html