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?
IP: Logged |
posted
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?
Posts: 37449 | Registered: May 1999
| IP: Logged |
posted
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).
Posts: 5879 | Registered: Apr 2001
| IP: Logged |
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.
Posts: 7954 | Registered: Mar 2004
| IP: Logged |
posted
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.htmlPosts: 15770 | Registered: Dec 2001
| IP: Logged |
posted
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.
Posts: 15770 | Registered: Dec 2001
| IP: Logged |
Blayne Bradley
unregistered
posted
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.
IP: Logged |
Blayne Bradley
unregistered
posted
nvm everything is A OH KAY. I handed in ym assignment and everything works.
IP: Logged |
posted
Excellent, Blayne! I'm glad you got it working. Scripting is one of the most enjoyable things you can do with a decent shell.
Posts: 37449 | Registered: May 1999
| IP: Logged |
Blayne Bradley
unregistered
posted
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.
IP: Logged |
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. Posts: 26071 | Registered: Oct 2003
| IP: Logged |
Blayne Bradley
unregistered
posted
lol, no I do scripting utilizing the bash shell/emacs. I have no idea what a Linux/Unix spreadsheet us.
IP: Logged |