2
I have a big file full of records like this
1, 2, 4, 5, 6
1, 3, 5, 6, 3
1, 4, 5, 6, 6
2, 4, 5, 5, 5
2, 3, 4, 5, 2
anyway I need to take the average of all rows with the same 1st number(key). i.e.
1, 3, 4.66, 5.66, 5
2, 3.5, 4.5, 5, 3.5
I know this is something awk/sed would be great for, I just don't have enough experience with them to accomplish it, thanks!
Also, what about averaging those columns together? so, after I output this to a file, id like to get another like:
1, 4.58
1, 4.125
The number of columns to add might not always be 4 either.
EDIT: this might be easier to do in gnuplot, so I mainly just need an answer to the first part.
Are the rows sorted (field one grouped) as you show in your example? You say the number of fields in a record might be different. Are they consistent within a file? – Paused until further notice. – 2010-07-20T19:37:39.143
well its just a sort -n to sort them so thats no problem. yeah. and yes they are consistent in the file, just not from file to file. If ya have an answer that depends on me specifying the number of fields, thats fine, Ill take that too. Just trying to get this scripted before I leave :) – Flamewires – 2010-07-20T21:26:25.047