Sponsored Content
Top Forums UNIX for Beginners Questions & Answers awk replace cells with NaN/delete if condition Post 303019080 by geomarine on Friday 22nd of June 2018 03:06:41 PM
Old 06-22-2018
Question awk replace cells with NaN/delete if condition

Hello, I will like to delete/replace $3 with NaN. condition $3>-2000 (file1.dat) to produce out.dat. I want to retain the structure of the table. I use this code, this output only $3. Any idea on how to modify this code. Thank you.

Code:
awk -v OFS='' '{for(i=1; i<=NF; i++) if ($i > -2000 || $i ==" > -2000 ")$i = NaN }1' file1.xyz > out.xyz

Code:
file1.dat
2181.0640997 2898.54726885 -4682.91259766
2182.06412909 2898.54726885 -2683.671875
2183.06415848 2898.54726885 -684.24609375
2184.06418787 2898.54726885 -1684.00146484
2185.06421726 2898.54726885 -2682.8671875
2186.06424665 2898.54726885 -4080.03369141
2187.06427604 2898.54726885 -1675.8359375
2188.06430543 2898.54726885 -3671.14892578
2189.06433482 2898.54726885 -6666.21142578
2190.06436421 2898.54726885 -1661.75146484
2191.0643936 2898.54726885 -4657.61230469
2192.06442299 2898.54726885 -1653.79052734
2193.06445238 2898.54726885 -5650.45507813
2194.06448177 2898.54726885 -4647.76513672
2195.06451116 2898.54726885 -1645.11816406
2196.06454055 2898.54726885 -6642.38427734

out1.dat
2181.0640997 2898.54726885 -4682.91259766
2182.06412909 2898.54726885 -2683.671875
2183.06415848 2898.54726885 -684.24609375
2184.06418787 2898.54726885 NaN
2185.06421726 2898.54726885 -2682.8671875
2186.06424665 2898.54726885 -4080.03369141
2187.06427604 2898.54726885 NaN
2188.06430543 2898.54726885 -3671.14892578
2189.06433482 2898.54726885 -6666.21142578
2190.06436421 2898.54726885 NaN
2191.0643936 2898.54726885 -4657.61230469
2192.06442299 2898.54726885 NaN
2193.06445238 2898.54726885 -5650.45507813
2194.06448177 2898.54726885 -4647.76513672
2195.06451116 2898.54726885 NaN
2196.06454055 2898.54726885 -6642.38427734

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Comparison of Cells in EXCEL using awk

Hi I have 2 csv files which looks like the following and i have to compare the 2 CSVs and create a third file such that if the value of the 1st cell in A.CSV and the value of the first cell in the B.CSV are same, it should print "SAME" in the third file or else print NOT SAME. Likewise i need... (19 Replies)
Discussion started by: meva
19 Replies

2. Shell Programming and Scripting

Delete line with sed or awk (with specified condition)

Hello. I'm trying to delete the lines of a file does not contain the letter "T " (for example) at position 26. So far, I could only print the result: awk '{if (substr ($ 1,1,26)! ~ / T /) print}' file.txt How I can do to eliminate the lines that meet this condition? Help please. ... (4 Replies)
Discussion started by: </kida>
4 Replies

3. UNIX for Dummies Questions & Answers

How do you delete cells from a space delimited text file given row and column number?

How do you delete cells from a space delimited text file given row and column number? Letś say the row number is r and the column number is c. Thanks! (5 Replies)
Discussion started by: evelibertine
5 Replies

4. UNIX for Dummies Questions & Answers

[Solved] Delete files with condition

I have a directory containing thousands of items “video files”, these items were generated by an application, which generates two items with the same name but with different extensions “.avi and .mp4”. There was a tool in my application to remove one item @ a time. Later I found this tool removes... (5 Replies)
Discussion started by: awadeid
5 Replies

5. Shell Programming and Scripting

Delete records within a file upon a condition

Hi Friends, I have the following file, cat input chr1 1000 2000 chr1 600 699 chr1 701 1000 chr1 600 1710 chr2 900 1800 Now, I would like to see the difference of Record1.Col2 - Record2.Col2 Record1.Col2 - Record2.Col3 Record1.Col3 - Record2.Col2 Record1.Col3 - Record2.Col3 ... (1 Reply)
Discussion started by: jacobs.smith
1 Replies

6. Shell Programming and Scripting

Delete if condition met in a column

i have a table like this: id, senderNumber, blacklist ----------------------------- 1 0835636326 Y 2 0373562343 Y 3 0273646833 Y and I want to delete automatically if a new inserted row on another table consist anything on senderNumber column above using a BASH Script I... (9 Replies)
Discussion started by: jazzyzha
9 Replies

7. UNIX for Dummies Questions & Answers

Replace with condition

I have file input a,b,b,b,ee,b3012dasda,53012,203,1,END,START b,c,b,b,ee,sdasdad,57483,203,,END,START a,b,b,b,ee,b3012dasda,53012,203,,END,START b,c,b,b,ee,sdasdad,57483,203,1,END,START I want every ",," in $9 replace with ,0, the output should be ... (3 Replies)
Discussion started by: radius
3 Replies

8. Shell Programming and Scripting

Delete File in a Directory Using a Condition

Hello, I have a directory with many files whose creation time is distributed all over the day. I need ANY 20 files per hour. So, I need 20 files for hour 00 20 files for hour 01 ... 20 files for hour 23 What I have done so far is not great. Here is the code: # get the Month a=`echo... (8 Replies)
Discussion started by: shekhar2010us
8 Replies

9. Shell Programming and Scripting

Delete complete row according to condition

Gents, Please can you help me. In the range 4-24 column the values are duplicate some times and I will like to delete the fist occurrence and keep the last only. The file is not sorted and I can sorted because from column 75 to the end the file is increase by time.. I have a file like this... (10 Replies)
Discussion started by: jiam912
10 Replies

10. Shell Programming and Scripting

awk to replace a specific field in certain condition

Hi, I have a file like below PRUM,67016800 ,CC ,C1,67016800 , ,Y,Y,2 ,CK,BX,FOX ,00000001,EA,00000001,20141120 00:00:00, ,N,Y,Y,CK ABCDEF... (7 Replies)
Discussion started by: mady135
7 Replies
CEXP(3) 						   BSD Library Functions Manual 						   CEXP(3)

NAME
cexp -- complex exponential function SYNOPSIS
#include <complex.h> double complex cexp(double complex z); long double complex cexpl(long double complex z); float complex cexpf(float complex z); DESCRIPTION
cexp(z) returns the complex exponential of z. cexp(conj(z)) = conj(cexp(z)), for all complex floating-point numbers z. SPECIAL VALUES
The conjugate symmetry of cexp() is used to abbreviate the specification of special values. cexp(+-0 + 0i) returns 1 + 0i. cexp(x + inf i) returns NaN + NaN i, and raises the invalid flag, for finite x. cexp(x + NaN i) returns NaN + NaN i, for finite x. cexp(inf + 0i) returns inf + 0i. For the following two cases, cis(y) denotes cos(y) + I*sin(y). cexp(-inf + yi) returns 0*cis(y), for finite y. cexp(inf + yi) returns inf*cis(y), for finite nonzero y. cexp(-inf + inf i) returns -0 + 0i. cexp(inf + inf i) returns -inf + NaN i, and raises the invalid flag. cexp(-inf + NaN i) returns -0 + 0i. cexp(inf + NaN i) returns -inf + NaN i. cexp(NaN + 0i) returns NaN + 0i. cexp(NaN + yi) returns NaN + NaN i for all nonzero numbers y. cexp(NaN + NaN i) returns NaN + NaN i. SEE ALSO
exp(3) clog(3) complex(3) STANDARDS
The cexp() 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 10:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy