in reply to average a column in tab-delimited file
Umm, maybe (seriously...) the way to do it is to put it into a database (e.g. an SQLite file), where the problem then becomes: SELECT COL1, COL2, AVERAGE(COL3), AVERAGE(COL4) FROM MEH GROUP BY COL1, COL2;
I am, once again, being perfectly serious. Consider how many other results you might also need to obtain against this data, either now or in the near future, which would be reduced to “a query, not a program,” if the format of this disk file were, instead of being delimited text, SQLite, with all of the power that the aforesaid public-domain tool brings to bear.
Since (IIRC...) SQLite already knows how to suck a delimited-file in, to make a table out of it, you literally might not need to “program” anything at all to accomplish this entire task.