And I need to get the first values block before the row without data (then the second values block before the blanck line and so on), and calculate the simple average value for each row, this is, sum all numbers and divide it by the number of values. I did the following bucle to separate the first values until it finds the blank line but doesn't work:
Separately, I used wc -l to count the values but the file name appears (let's say: wc -l list.txt gives 10 list.txt).
I would appreciate your support to solve my problem.
Thanks in advance.
Last edited by vgersh99; 06-10-2010 at 01:26 PM..
Reason: code tags, please!
I need to calculate the average of the first column and get one value, so the sum is:
= 272134.5446 (2721345.446/10)
The same with the second column, and get one value.
But the point is that I have to do this for each value block (where both blocks are separated by a blank line). I have 20 000 rows, like 500 value blocks. So, for the two blocks showed above, I will get, let's say:
272134.543 6680572.705 (first value block)
272134.546 6680572.713 (second value block)
It is not important how the pair of output values is (ie. comma-separated, etc), it is just important the pair of output values.
Thanks for your answer.
Last edited by vgersh99; 06-10-2010 at 01:28 PM..
Reason: code tags, please!
It is bit ugly, but it has one advantage, being able to produce proper outcome when additional columns of numbers are added to your data file. Run it like that:
i have a file with 2 columns. i want to calculate the average of column 1 based on the values of column 2. here's how the file looks like. i want to calculate the sums of numbers corresponding to 1 and then calculate the average. same for numbers corresponding to zero. any help with a code would... (1 Reply)
I have no idea how to even get started with this script.
I need to average field 3 for each of the unique identifiers found in field 1. However, I only want to average these rows when field 2 is equal to 1506 - 2000 (note that i replaced the values field 2 for security reasons, but the real... (6 Replies)
Hi
I have a requirement, where i will receive multiple files in a folder (say: /fol1/fol2/). There will be at least 14 to 16 files. The size of the files will different, some may be 80GB or 90GB, some may be less than 5 GB (and the size of the files are very unpredictable). But the names of the... (10 Replies)
Could anybody help with this?
I have input below .....
david,39
david,39
emelie,40
clarissa,22
bob,42
bob,42
tim,32
bob,39
david,38
emelie,47
what i want to do is count how many names there are with different ages, so output would be like this ....
david,2
emelie,2
clarissa,1... (3 Replies)
Hi Friends,
In continuation to my earlier post
https://www.unix.com/shell-programming-scripting/99166-script-find-average-given-column-also-specified-number-rows.html
I am extending my problem as follows.
Input:
Column1 Column2
MAS 1
MAS 4 ... (2 Replies)
Hi friends
I have 100 files in my directory. Each file look like this..
Temp1 Temp2 Temp3
MAS 1 2 3
MAS 4 5 6
MAS 7 8 9
Delhi 10 11 12
Delhi 13 14 15
Delhi 16 17 ... (4 Replies)
Hi All
I like to know how can we calculate the number of rows and the average of the values present in the file. I will not know what will be the rowcount, which will be dynamic in nature of the file.
eg.
29
33
48
30
28 (6 Replies)
Hi,
I'm, new to shell scripting, I have a requirement where I have to split an incoming file into separate files each containing a maximum of 3 million rows.
For e.g: if my incoming file say In.txt has 8 mn rows then I need to create 3 files, in which two will 3 mn rows and one will contain 2... (2 Replies)
I've been trying all night to come up with a script that will take a file that contains job completion times like this as input:
18:30
17:45
16:39
18:01
17:50
...
and figure the Average completion time. I've tried several things, and I just can't seem to get it to figure correctly. I'm... (5 Replies)