Replace 4th field if null


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Replace 4th field if null
Prev   Next
# 1  
Old 08-03-2009
Replace 4th field if null

Hi ..
Can some one please suggest me how to replace 4th field(column) of a .csv file with "NA" if it is null.
Input file data:
Code:
|A|21|B1||1.1|
|A|21|C|RAGH|1.1|
|A|21|D1||1.1|
|A|21|C|YES|1.1

Expected Output
Code:
|A|21|B1|NA|1.1|
|A|22|C|RAGH|1.1|
|B|23|D1|NA|1.1|
|A|24|C|YES|1.1|

Thank you...

Next time use CODE-tags when posting code, data or logs to enhance readability and to preserve formatting like indention etc., ty.
Also your post got stuck in the moderation queue since it contains URLs. Just remind of it posting URLs next time - maybe change them a bit so post doesn't get lost.

Last edited by pasupuleti81; 08-03-2009 at 10:34 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To find char field and replace null

hi, i having a file with | seperated in which i need to search char in 3rd column and replace with null. i need to replace only the coulmn where character occurs in 3rd field for eg: file1.txt xx|yy|xx|12 output file: xx|yy||12 (5 Replies)
Discussion started by: rohit_shinez
5 Replies

2. Shell Programming and Scripting

Replace a field where values are null in a file.

Hi, I've a pipe delimited file and wanted to replace the 3rd field to 099990 where the values are null. How can I achieve it using awk or sed. 20130516|00000061|02210|111554|03710|2|205069|SM APPL $80-100 RTL|S 20130516|00000061|02210|111554|03710|2|205069|SM APPL $80-100 RTL|S... (12 Replies)
Discussion started by: rudoraj
12 Replies

3. Shell Programming and Scripting

How to extract 4th field if numerics?

I have a file which contains fields comma separated & with each field surrounded by quotes. The 4th field contains either a serial number, the text ABC, the text XYZ or it's blank. I want to only extract records which have a serial number. Here's some sample data: > cat myfile... (4 Replies)
Discussion started by: CHoggarth
4 Replies

4. Shell Programming and Scripting

perl script to split the text file after every 4th field

I had a text file(comma seperated values) which contains as below 196237,ram,25-May-06,ram.kiran@xyz.com,204183,Pavan,4-Jun-07,Pavan.Desai@xyz.com,237107,ram Chandra,15-Mar-10,ram.krishna@xyz.com ... (3 Replies)
Discussion started by: giridhar276
3 Replies

5. Shell Programming and Scripting

Replace 0's with NULL

Hi all, Need a small help I am in lookout for a command that changes 0's to NULL in my file, The content will look like 1139,223108,R,2009,0,854,854,854,732,854,854,854,854,854 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,... (3 Replies)
Discussion started by: Sri3001
3 Replies

6. Shell Programming and Scripting

How to replace all after 4th character in line ?

How to replace all after 4 character at line? & convert to upper case ? google.com -> GOOG (2 Replies)
Discussion started by: Trump
2 Replies

7. Shell Programming and Scripting

awk Problem while insert null field to file

Dear All, I have the following input file. I want to replace data with null values. I/P File: 9022334455|2008-12-06 06:10:21|2|Error@@@|esoo8erp| 9024334432|2008-12-06 08:40:59|6|Error@@@|6y2o8e6r| O/P File: 9022334455||2||esoo8erp| 9024334432||6||6y2o8e6r| ... (4 Replies)
Discussion started by: hanu_oracle
4 Replies

8. Shell Programming and Scripting

display file where 4th field = 200704

Hello I have a file which is pipe delimited. The 4 th field has value like 200704 or 200705 etc. Now i have to get only those records where 4th field is 200704 How can i do this? I have to get the whole record where 4th field = 200704 (7 Replies)
Discussion started by: vasuarjula
7 Replies

9. AIX

display file where 4th field = 200704

Hello I have a file which is pipe delimited. The 4 th field has value like 200704 or 200705 etc. Now i have to get only those records where 4th field is 200704 How can i do this? I have to get the whole record where 4th field = 200704 (4 Replies)
Discussion started by: vasuarjula
4 Replies

10. UNIX for Dummies Questions & Answers

Grep for NULL for a specific field in a unix file

hii.. I have a pipe delimited file For ex: TEST_1-8J6TZN|ASLANK|BHR-09||TRAM I want to grep for NULL in the 4th field only from the above file Please suggest Also let me know if there is any limitation in the suggested command Thanks all in advance..!! (5 Replies)
Discussion started by: sureshg_sampat
5 Replies
Login or Register to Ask a Question
DELAY.4TH(8)						    BSD System Manager's Manual 					      DELAY.4TH(8)

NAME
delay.4th -- FreeBSD debugging boot module DESCRIPTION
The file that goes by the name of delay.4th is a set of commands designed to add debugging capabilities to loader(8). The commands of delay.4th by themselves are not enough for most uses. Please refer to the examples below for the most common situations, and to loader(8) for additional commands. Before using any of the commands provided in delay.4th, it must be included through the command: include delay.4th This line is present in /boot/beastie.4th file, so it is not needed (and should not be re-issued) in a normal setup. The commands provided by it are: delay_execute Executes the [string] procedure stored in the delay_command environment variable after loader_delay seconds. If the optional delay_showdots environment variable is set, a continuous series of dots is printed. During the duration, the user can either press Ctrl-C (or Esc) to abort or ENTER to proceed immediately. The environment variables that effect its behavior are: delay_command The command to be executed by delay_execute. loader_delay The duration (in seconds) to delay before executing delay_command. delay_showdots If set, will cause delay_execute to print a continuous series of dots during the delay duration. FILES
/boot/loader The loader(8). /boot/delay.4th delay.4th itself. /boot/loader.rc loader(8) bootstrapping script. EXAMPLES
Introducing a 5-second delay before including another file from /boot/loader.rc: include /boot/delay.4th set delay_command="include /boot/other.4th" set delay_showdots set loader_delay=5 delay_execute SEE ALSO
loader.conf(5), beastie.4th(8), loader(8), loader.4th(8) HISTORY
The delay.4th set of commands first appeared in FreeBSD 9.0. AUTHORS
The delay.4th set of commands was written by Devin Teske <dteske@FreeBSD.org>. BSD
May 18, 2011 BSD