This is topic Linux help in forum Books, Films, Food and Culture at Hatrack River Forum.


To visit this topic, use this URL:
http://www.hatrack.com/ubb/main/ultimatebb.php?ubb=get_topic;f=2;t=039157

Posted by Blayne Bradley (Member # 8565) on :
 
Ok,

name phone # Jan Feb Mar Total Donated
-------------------------------------------
Dan Savage (514) 976-9903 250 340 670 4000

there's a list of said names, now what would the formula be for calculated the average total donated and the total amount donated for evryone on list?
 
Posted by TomDavidson (Member # 124) on :
 
When you say "Linux help," does this mean you want to run this sum from within the operating system, and not from a spreadsheet/ledger/word processing program?
 
Posted by ludosti (Member # 1772) on :
 
Now, I'm not familiar with linux, but the total amount donated would be the sum of all the figures in the Total Donated column and the average total donated (across all the people, rather than the average monthly donation from a single person) would be the average of all those same figures (the sum of the Total Donated divided by the number of people/rows).
 
Posted by ElJay (Member # 6358) on :
 
quote:
Originally posted by TomDavidson:
When you say "Linux help," does this mean you want to run this sum from within the operating system, and not from a spreadsheet/ledger/word processing program?

And if so, why? Any spreadsheet program will do it quickly and easily for you.
 
Posted by fugu13 (Member # 2859) on :
 
This really has nothing to do with Linux, though I assume you want to do it on Linux.

As for formulas, I highly suggest thinking back to your first algebra class.

If you don't find that possible, the average for a value is found by adding up all the instances of that value and dividing by the total number of instances. If a dataset is 1,2,3, the average is 2, because that's 1+2+3 = 6, divided by the number of numbers in the dataset, 3.

The total amount donated by everyone is found by adding up the total amounts donated by each person. Since you'll do this on the route to figuring the average, I suggest doing this one first then using the total in the calculation of the average.

On the off chance you meant you wanted a program to do this, rather than a formula, and assuming there are no delimiters between the records, I'd delete the first two lines in the file (just to make it easy; we could use a command line program to chop them off for feeding to the next one), then go read the man page for awk. This tutorial is good, too: http://www.vectorsite.net/tsawk.html
 
Posted by fugu13 (Member # 2859) on :
 
ElJay: I wonder somewhat myself. It may be he's in a situation where its advantageous to automate the process, something spreadsheets are excellent at not doing but making people think they did.
 
Posted by Blayne Bradley (Member # 8565) on :
 
I was writing a script file, but nvm I solved it, next problem is that I need to sort a list of said names by their last names and gah I dont think i could explain it well enough...

{printf ("%5__%5" , $1, $2) | sort ~~~}

i need to sort by last names utilizing a space as a field separator, -F": " would be enough for awk but my teacher says I need something related to a -k command.
 
Posted by Blayne Bradley (Member # 8565) on :
 
nvm everything is A OH KAY. I handed in ym assignment and everything works.
 
Posted by TomDavidson (Member # 124) on :
 
Excellent, Blayne! I'm glad you got it working. Scripting is one of the most enjoyable things you can do with a decent shell.
 
Posted by Blayne Bradley (Member # 8565) on :
 
bash shell I believe, we had a list of names, phone numebrs and campaign contributions as the examle above ^^, and we had to make a script that showed it in a special format and gave the average contribution, the total contribution, the highest subtotal contributiion per person.

Then for all people who contributed >= 500$ we had to print them out sorted alphabetically by last names and show only those who contributed more or equal to 500.

I ended up with alot of debugging. But eventually I figured out everything with the help of class mates and teachers. Now I have to prepare for next test by reviewing the assignment and reviewing the stuff in the book.
 
Posted by Dagonee (Member # 5818) on :
 
quote:
ElJay: I wonder somewhat myself. It may be he's in a situation where its advantageous to automate the process, something spreadsheets are excellent at not doing but making people think they did.
Maybe the way you work with spreadsheets. [Wink]
 
Posted by Blayne Bradley (Member # 8565) on :
 
lol, no I do scripting utilizing the bash shell/emacs. I have no idea what a Linux/Unix spreadsheet us.
 


Copyright © 2008 Hatrack River Enterprises Inc. All rights reserved.
Reproduction in whole or in part without permission is prohibited.


Powered by Infopop Corporation
UBB.classic™ 6.7.2