Sponsored Content
Top Forums Shell Programming and Scripting Averaging each row with null values Post 302611081 by ida1215 on Thursday 22nd of March 2012 08:42:45 AM
Old 03-22-2012
Thank you very much for the code its just what I needed, thanks for saving my night,SmilieSmilie

---------- Post updated at 09:42 PM ---------- Previous update was at 08:53 PM ----------

There is one more glitch, am sorry for missing this out. I have some rows with entirely null values and as such using the previous code I ended up with getting fatal error (attempted division by zero). how can it be resolved? how to tell the script that when all values in the row is null (NaN), put NaN on that corresponding row average.
Code:
1.4 1.2 1.5 NaN 1.6 = (1.4+1.2+1.5+1.6)/4
1.3 1.1 NaN 1.3 NaN = (1.3+1.1+1.3)/3 
2.4 1.3 1.5 NaN 1.5 = (2.4+1.3+1.5+1.5)/4
NaN 1.2 NaN 1.4 NaN = (1.2+1.4)/2
NaN NaN NaN NaN NaN = NaN
NaN NaN NaN NaN NaN = NaN

Many thanks.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

averaging column values with awk

Hello. Im just starting to learn awk so hang in there with me...I have a large text file formatted as such everything is in a single column ID001 value 1 value 2 value....n ID002 value 1 value 2 value... n I want to be able to calculate the average for values for each ID from the... (18 Replies)
Discussion started by: johnmillsbro
18 Replies

2. Shell Programming and Scripting

How to insert data befor some field in a row of data depending up on values in row

Hi I need to do some thing like "find and insert before that " in a file which contains many records. This will be clear with the following example. The original data record should be some thing like this 60119827 RTMS_LOCATION_CDR INSTANT_POSITION_QUERY 1236574686123083rtmssrv7 ... (8 Replies)
Discussion started by: aemunathan
8 Replies

3. UNIX for Advanced & Expert Users

How to Compare Null values??

Hi, Can someone help me comparing Null values. Scenario is as follows: I have a variable which "cache_prd" which can have either some integer or nothing(Null) if it is integer I have to again do some comparision but these comparisons give me this error:( "line 32: [: 95: unary operator... (3 Replies)
Discussion started by: Yagami
3 Replies

4. Shell Programming and Scripting

sorting null values

Hi I have a file with the values abc res set kls lmn ops i want to sort this file with the null values at the bottom of the file OUTPUT should look like this abc kls lmn ops (6 Replies)
Discussion started by: vickyhere
6 Replies

5. Shell Programming and Scripting

How to averaging column based on first column values

Hello I have file that consist of 2 columns of millions of entries timestamp and throughput I want to find the average (throughput ) for each equal timestamp before change it to proper format e.g : i want to average 2 coloumnd fot all 1308154800 values in column 1 and then print... (4 Replies)
Discussion started by: aadel
4 Replies

6. Shell Programming and Scripting

Loop for row-wise averaging of multiple files using awk

Hello all, I need to compute a row-wise average of files with a single column based on the pattern of the filenames. I really appreciate any help on this. it would just be very difficult to do them manually as the rows are mounting to 100,000 lines. the filenames are as below with convention as... (2 Replies)
Discussion started by: ida1215
2 Replies

7. Shell Programming and Scripting

How to use sort with null values?

Hello everyone I am doing a join command. Obviously, before I need two files sorted first. ( Both files have headers and have about 2 million lines each one ) The problem is, one of the files has null values in the key to sort (which is the first filed ). For example I have the original... (4 Replies)
Discussion started by: viktor1985
4 Replies

8. Shell Programming and Scripting

File values alwaya null

Hi All , below is my shell program. !/bin/sh set -x #---------------------------------------------------------------------------------------- # Program : weekly_remove_icd_file.sh # Author : # Date : 04/06/2013 # Purpose : Execute the script to... (3 Replies)
Discussion started by: krupasindhu18
3 Replies

9. Shell Programming and Scripting

Check null values column

hi, I had a small question.I had a file from which i need to extract data. I have written the below script to check if the file exists and if it exists extract requierd columns from the file. IFILE=/home/home01/Report_1.csv OFILE=/home/home01/name.csv.out1 if #Checks if file exists... (1 Reply)
Discussion started by: Vivekit82
1 Replies

10. Shell Programming and Scripting

How to perform averaging of values for particular timestamp using awk or anythoing else??

I have a file of the form. 16:00:26,83.33 16:05:26,83.33 16:10:26,83.33 16:15:26,83.33 16:20:26,90.26 16:25:26,83.33 16:30:26,83.33 17:00:26,83.33 17:05:26,83.33 17:10:26,83.33 17:15:26,83.33 17:20:26,90.26 17:25:26,83.33 17:30:26,83.33 For the timestamp 16:00:00 to 16:55:00, I need to... (5 Replies)
Discussion started by: Saidul
5 Replies
CTANH(3)						   BSD Library Functions Manual 						  CTANH(3)

NAME
ctanh -- complex hyperbolic tangent function SYNOPSIS
double complex ctanh(double complex z); long double complex ctanhl(long double complex z); float complex ctanhf(float complex z); DESCRIPTION
ctanh(z) computes the hyperbolic tangent of the complex floating-point number z. For all complex floating point numbers z, ctanh(conj(z)) = conj(ctanh(z)), ctanh(-z) = -ctanh(z). SPECIAL VALUES
The symmetries of ctanh() are used to abbreviate the specification of special values. ctanh(0 + 0i) returns 0 + 0i. ctanh(0 + inf i) returns NaN + NaN i, and raises the invalid flag. ctanh(0 + NaN i) returns NaN + NaN i. ctanh(x + inf i) returns NaN + NaN i, and raises the invalid flag, for finite nonzero x. ctanh(x + NaN i) returns NaN + NaN i, for finite nonzero x. ctanh(inf + 0i) returns 1 + 0i. ctanh(inf + yi) returns 1 +- 0i, for finite positive y, with the sign chosen to match the sign of sin(2y). ctanh(inf + inf i) returns 1 + 0i. ctanh(inf + NaN i) returns 1 + 0i. ctanh(NaN + 0i) returns NaN + 0i. ctanh(NaN + yi) returns NaN + NaN i, for nonzero numbers y. ctanh(NaN + NaN i) returns NaN + NaN i. NOTES
SEE ALSO
ctan(3) complex(3) STANDARDS
The ctanh() function conforms to ISO/IEC 9899:2011. 4th Berkeley Distribution December 11, 2006 4th Berkeley Distribution
All times are GMT -4. The time now is 09:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy