Inserting text and modifying the file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Inserting text and modifying the file
# 1  
Old 04-11-2009
Inserting text and modifying the file

I am in a dire need of doing this job , please help from shell script or perl script. It will be highly appreciated.


Please have a look at the following INPUT file;
The first 14 rows are not of interest but I want them to be included in the output file as they are. From the row 14 (identifier LOG5 in the first column), I want to make changes as shown in the output file below the input file ( I did it manually). Notice that I created two extra columns. From the input file, the columns of my interest are the 2nd column and the fourth column. In the output file you will notice there are 6 columns.
requirement 1: The column 6 is generated based on the 4th column in the input file i.e If the code is 1.0000 then the entry in column 6 will say "FACIES 1", if the code is 4.0000 then the value in the new coulmn will be "FACIES 3", and for every row where the 4th column in the input file is 16, the new column value against that should be "FACIES 8" and if the code is 18.0000 then the new column should have "FACIES 5".
Requirment 2: For all the lines where the code is repeated only once, should be deleted.
Requiremnt 4: only the first value from colunm #2 for each occurance of the chunk of code values and the last value from column # 2 should be output (Notice column # 5 in the output file). Please have a look at the OUTPUT file.

Well Data Export
Project : XXXX_ABC09
Cartographic System : XXX YY ZZZ - ZZZ02
Depth Mode : MD
Depth Unit : Common feet
Distance Unit : meters
Format File : /xxxx/yyy/zzzzzzz/aaa/bbb/cccccc_12345.abc
Date : Sat Apr 11 09:23:01 2009

LOG1 UWI: 1234567 Depth:
LOG2 Common: ABCD_123_0
LOG3 Curve: AAA_FACIES Run #: -1
LOG4 Measr. Depth TVD Depth Log Value
LOG5 1591.0000 1590.3907 1.0000
LOG5 1591.5000 1590.8904 1.0000
LOG5 1592.0000 1591.3900 1.0000
LOG5 1592.5000 1591.8895 1.0000
LOG5 1593.0000 1592.3892 1.0000
LOG5 1593.5000 1592.8888 1.0000
LOG5 1594.0000 1593.3883 1.0000
LOG5 1594.5000 1593.8879 1.0000
LOG5 1595.0000 1594.3876 1.0000
LOG5 1595.5000 1594.8871 1.0000
LOG5 1596.0000 1595.3867 1.0000
LOG5 1596.5000 1595.8864 1.0000
LOG5 1597.0000 1596.3859 2.0000
LOG5 1597.5000 1596.8855 4.0000
LOG5 1598.0000 1597.3851 4.0000
LOG5 1598.5000 1597.8846 4.0000
LOG5 1599.0000 1598.3843 4.0000
LOG5 1599.5000 1598.8839 4.0000
LOG5 1600.0000 1599.3834 4.0000
LOG5 1600.5000 1599.8831 4.0000
LOG5 1601.0000 1600.3827 4.0000
LOG5 1601.5000 1600.8823 4.0000
LOG5 1602.0000 1601.3818 4.0000
LOG5 1602.5000 1601.8815 1.0000
LOG5 1603.0000 1602.3811 1.0000
LOG5 1603.5000 1602.8806 1.0000
LOG5 1604.0000 1603.3802 1.0000
LOG5 1604.5000 1603.8799 1.0000
LOG5 1605.0000 1604.3794 4.0000
LOG5 1605.5000 1604.8790 4.0000
LOG5 1606.0000 1605.3787 4.0000
LOG5 1606.5000 1605.8782 3.0000
LOG5 1607.0000 1606.3778 16.0000
LOG5 1607.5000 1606.8774 16.0000
LOG5 1608.0000 1607.3770 16.0000
LOG5 1608.5000 1607.8766 16.0000
LOG5 1609.0000 1608.3762 16.0000
LOG5 1609.5000 1608.8757 16.0000
LOG5 1610.0000 1609.3754 16.0000
LOG5 1610.5000 1609.8750 16.0000
LOG5 1651.0000 1650.3434 18.0000
LOG5 1651.5000 1650.8430 18.0000


THE OUTPUT FILE IS WHAT I WANT TO GENERATE FROM ABOVE FILE;

Well Data Export
Project : XXXX_ABC09
Cartographic System : XXX YY ZZZ - ZZZ02
Depth Mode : MD
Depth Unit : Common feet
Distance Unit : meters
Format File : /xxxx/yyy/zzzzzzz/aaa/bbb/cccccc_12345.abc
Date : Sat Apr 11 09:23:01 2009

LOG1 UWI: 1234567 Depth:
LOG2 Common: ABCD_123_0
LOG3 Curve: AAA_FACIES Run #: -1
LOG4 Measr. Depth TVD Depth Log Value
LOG5 1591.0000 1590.3907 1596.5000 1.0000 FACIES 1
LOG5 1597.5000 1596.8855 1602.0000 4.0000 FACIES 3
LOG5 1602.5000 1601.8815 1604.5000 1.0000 FACIES 1
LOG5 1605.0000 1604.3794 1606.0000 4.0000 FACIES 3
LOG5 1607.0000 1606.3778 1610.5000 16.0000 FACIES 8
LOG5 1651.0000 1650.3434 1651.5000 18.0000 FACIES 5
# 2  
Old 04-11-2009
have you started on something?
# 3  
Old 04-11-2009
No I have not started anything and I actually wont be able to do it with my skills anyway.
# 4  
Old 04-11-2009
all of us, me included, are not born with those skills either. where do you think we acquire those "skills"? its takes a bit of hard work. if you are being paid to do this job, at least do and start with something. what kind of programming experience do you have?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removing duplicate sequences and modifying a text file

Hi. I've tried several different programs to try and solve this problem, but none of them seem to have done exactly what I want (and I need the file in a very specific format). I have a large file of DNA sequences in a multifasta file like this, with around 15 000 genes: ... (2 Replies)
Discussion started by: 4galaxy7
2 Replies

2. Shell Programming and Scripting

Inserting text in file names while copying them.

I'm trying to find a Bourne shell script that will copy files from one directory using a wild card for the file name (*) and add some more characters in the middle of the file name as it is copied. As an example: /u01/tmp-file1.xml => /u02/tmp-file1-20130620.xml /u01/tmp-file2.xml => ... (6 Replies)
Discussion started by: Tony Keller
6 Replies

3. UNIX for Dummies Questions & Answers

Inserting text into a file with awk or sed

Hello, I've been trying to get a script working that fetches weather-data and converts it into an .ics file. The script works so far put I'm stuck at the point where I need to add specific static data. A thorough search through the forum did not point me into the right direction. #!/bin/bash... (3 Replies)
Discussion started by: Schubi
3 Replies

4. Shell Programming and Scripting

Help with sed and inserting text from another file

I need to insert text from one file into another file after specific term. I guess sed is the best method of doing this and I can insert a specified text string using this script but I am not sure how to modify it to insert text from another file: #!/bin/sh sed 's/\<VirtualHost... (17 Replies)
Discussion started by: barrydocks
17 Replies

5. Shell Programming and Scripting

Small query on modifying the text of file

Hi, I have file with the following text, /analysis2012/533/mc_S10_533/DYJets50/vgtree_1_1_33l.root /analysis2012/533/mc_S10_533/DYJets50/vgtree_2_5_33l.root /analysis2012/533/mc_S10_533/DYJets50/vgtree_6_7_33l.root and many such files. For some operation on these files, I would like... (9 Replies)
Discussion started by: emily
9 Replies

6. Shell Programming and Scripting

Inserting text into a new file

Hi all, I want to create a file and then insert some text into it. I'm trying to create a .sh script that will create a new python file from a template. Can someone tell me why this won't work, touch $1 | sed -e '1i\Some test code here' Sorry I'm quite new to all this! Just as a side... (3 Replies)
Discussion started by: ahodgson
3 Replies

7. UNIX for Dummies Questions & Answers

Inserting a column into a text file

I have a tab delimited text file with multiple columns (data.txt). I would like to insert a column into the text file. The column I want to insert is in a text file (column.txt). I want to insert it into the 5th column of data.txt. How do I go about doing that? Thanks! (2 Replies)
Discussion started by: evelibertine
2 Replies

8. Shell Programming and Scripting

inserting a string to a text file

Hello Can somebody please help me with the following script? I'm trying to create a text file with 20 blank lines and then insert a string in line 2 but nothing is printed in the itxtfile. I can create the file with 20 blank lines but when I "tell" it to print something on the second line, it... (4 Replies)
Discussion started by: goude
4 Replies

9. Shell Programming and Scripting

inserting subscriber no in text file using KSH....

:confused:Dears , I have text file I need to insert the subscriber number at position 32, and need to keep the next field at position 53 (no increasing of the record lenght), I mean I just want to replace the spaces at position 32 with subscirber number . for example A B A ... (1 Reply)
Discussion started by: atiato
1 Replies

10. Shell Programming and Scripting

Help need in modifying the text of .txt file

Hi All, I've written a shell script in which i defined two varibles for example: str=1.0.0.15 timeStamp=2008.03.08 now using this varibles i need to modify a text file. The text content looks like this ************************ * packageNumber : 1.0.0.14 * * date :... (2 Replies)
Discussion started by: vinna
2 Replies
Login or Register to Ask a Question