473,396 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

awk related questin

how can i get the sum and get average of records of files using awk programming

i have several output files like this

file 1
year col1 col2 col3 col4
1 0.4 0.1 0.3 0.8
1 0.3 0.2 0.9 2
2 0.1 0.3 0.8 0.7
2 0.2 0.4 0.9 0.7
3 0.4 0.3 0.8 0.3
3 0.2 0.4 0.4 0.2
4 0.8 0.4 0.8 0.3
4 0.5 0.4 0.5 0.5

file 2
year col1 col2 col3 col4;
1 0.4 0.1 0.3 0.8
1 0.3 0.2 0.9 2
2 0.1 0.3 0.8 0.7
2 0.2 0.4 0.9 0.7
3 0.4 0.3 0.8 0.3
3 0.2 0.4 0.4 0.2
4 0.8 0.4 0.8 0.3
4 0.5 0.4 0.5 0.5

file 3
year col1 col2 col3 col4
1 0.4 0.1 0.3 0.8
1 0.3 0.2 0.9 2
2 0.1 0.3 0.8 0.7
2 0.2 0.4 0.9 0.7
3 0.4 0.3 0.8 0.3
3 0.2 0.4 0.4 0.2
4 0.8 0.4 0.8 0.3
4 0.5 0.4 0.5 0.5

and i want the average out puts of all the records of a files to be summed and averaged in to one file and looks like this

year col1 col2 col3 col4
1
1
2
2
3
3
4
4
5
5
Jan 21 '10 #1
2 1303
donbock
2,426 Expert 2GB
Please clarify.
  1. Do you a want separate output file for each input file; or do you want a single output file that combines the information from all the input files.
  2. You say you want to "sum and average" the records, but your example output looks like you merely want to print the first column of each record and throw away the rest of the data.
Jan 21 '10 #2
i just want to get the average of each points of (year1, col1), (year1,col2), (year1,col3),(year1,col4), (year2,col1), (year2,col2), (year2, col3), (year2,col4), (year3,col1)....................... (year4, col4).


and each point should be a sum of 50 files points. all the 50 files are same replicates with the same content and form
Jan 21 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jason | last post by:
I am trying to filter records in a primary form based on records in related tables. The data in the related tables is being displayed in the primary form through subforms. To be more specific, I...
2
by: Danial Juka | last post by:
Hi All, I am making a content management system in asp.net. I want to show max 5 related links to other articles that somehow relate to the current article. An example of what I am looking...
2
by: Jim in Arizona | last post by:
Usually, If i need special formatting, I don't use the datagrid control and use a loop that processes a table for each record read from the database (as in classic asp) like so: ...
9
by: clintonG | last post by:
The Barnes & Noble stores in and around Milwaukee, Wisconsin have removed or are removing all of the Microsoft platform programming and support magazines from their shelves. Not one single magazine...
3
by: ss | last post by:
hI, Where do I created the Session Related things in ASP.NET 2.0? How do I do that? Could anybody give some sample code? bye
1
by: David | last post by:
Hi, I have an MS Access app which lets me create a new product by copying data from another selected product. All works fine, except one of the copy updates which I cannot fathom. The code...
4
by: HLCruz via AccessMonster.com | last post by:
I am working with a database that has client information separated in to 4 related tables - tFolder, tAddress, tEmail, tPhone number. In addition there are related tables tGifts and tCalls. The...
3
by: stair | last post by:
I have 2 tables, 1 table containing a list of items and a second with list of documents related to the items and the status of those documents. It is valid to have no documents related to a...
11
misscrf
by: misscrf | last post by:
I have received data which contains similar records, where the customers have similar records. A customer, i.e. Jane Doe may have moved, or something, or a change to her account. When that happened...
0
by: cannonpm | last post by:
Greetings and salutations. I have developed an A2K3 MDB and have a search form modeled after Allen Browne's search form (http:// allenbrowne.com/ser-62.html). It works well except for records which...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.