Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem Converting data file 1

Status
Not open for further replies.

fabien

Technical User
Sep 25, 2001
299
AU
Hi!

I have the following data file:
PUITS surface X (fsurface Y (ftBOTTOMWB LB1 LB2 UB1 UB2 UB3 TOP_BURGAN TOP_MAUDDUD W1 W2 W3 W4 W5 W6 W7 W8
MN-0001 2455354.3 10549550.5 6600.0 INDT 6361.4 6320.6 6283.5 6257.7 6197.5 6193.6 6176.0 6159.3 6129.7 6093.9 6051.4 5995.6 5976.4 5943.1
MN-0002 2450419.9 10546620.7 6601.2 6597.2 6344.5 6301.2 6283.7 6241.2 6182.7 6177.9 6165.3 6149.5 6124.5 6071.7 6018.3 5961.7 5939.2 5900.8
...

I need to reformat it like that
DUM WELL PICK DEPTH INT
1 MN-0001 LB2 6361.4 toto
1 MN-0001 UB1 6320.6 toto
...

with following format
DUM: col 1-2 WELL: col 5-25, PICK: col 30-60 , DEPTH: col 65-85, INT: col 90-100

where
1)INT= toto is a constant for all the lines

2) If DEPTH=INDT then do not write out the line (like for MN_0001/LB1)

Many thanks!
 
Something like this ?
BEGIN{
fmt="%-3s %-21s %-31s %-21s %-10s\n"
printf fmt,"DUM","WELL","PICK","DEPTH","INT"
fmt="%-2s %-21s %-31s %-21s %-10s\n"
}
NR==1{for(i=0;i<15;++i)n=$(NF-14+i);next}
{for(i=0;i<15;++i)
if($(i+5)!="INDT")
printf fmt,0+substr($1,6),$1,n,$(i+5),"toto"
}

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top