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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with data file

Status
Not open for further replies.

fabien

Technical User
Sep 25, 2001
299
AU
Hi!

I have an ASCII file with the following data
....
C33
C34
C35 HE94-140 CDP 205 == SP 1001

C36 HE94-140 CDP 405 == SP 1101

C37
C38
C39
C40 CDPS 1 TO 9944 SPS 1001 TO 5873
...
the same with different values many times

What I want to extract is
HE94-140 1001 205 1 9944 (from C35 and C40)
HE94-140 1101 405 1 9944 (from C36 and C40)

What is the best thing to do?

Thanks for your help

 
awk '{
if ($6 == "SP") {
HE[NR]=$2;
CDP[NR]=$4;
SP[NR]=$7;
}
if ($2 == "CDPS")
for (i in HE)
if (SP>=$7 && SP<=$9 && CDP>=$3 && CDP<=$5)
OTH=$3 &quot; &quot; $5;
}
END {
for (i in HE)
print HE, SP, CDP, OTH;
}' file1
 
Or maybe

/^C35 /{a1=$2 &quot; &quot; $7 &quot; &quot; $4}
/^C36 /{a2=$2 &quot; &quot; $7 &quot; &quot; $4}
/^C40 /{print a1,$3,$5;print a2,$3,$5}


CaKiwi

&quot;I love mankind, it's people I can't stand&quot; - Linus Van Pelt
 
Thanks for suggestions guys! Ygor: why did you add this test:
if (SP>=$7 && SP<=$9 && CDP>=$3 && CDP<=$5) ?
 
I was trying to guess what you meant by: &quot;the same with different values many times&quot;.
 
Ygor,

What I mean is that the data I have is based on the example I gave repeated many times like and I don't think your test works because I get no values for OTH sometimes.

Below is a longer example
TEXT HEADER:

C01 SURVEY : 1994 HE94 2D SEISMIC SURVEY
C02 LINE: HE94-140 PERMIT: WA-252/255-P DIRECTION: 123 DEGREES
C03
C04 RAW STACK
C05
C06 PROCESSING PARAMETERS: PROCESSING LENGTH(SEC): 8 SAMPLE PERIOD(MS): 4
C07
C08 TRANSCRIPTION: SEGD INTO SPT'S INTERNAL FORMAT
C09 GAIN RECOVERY
C10 INSTRUMENT DEPHASE
C11 RESAMPLE FROM 2 MS TO 4 MS
C12 FREE FORM DESIGN F-K FILTER (ACCEPT)
C13 ARRAY SIMULATION AND TRACE DECIMATION (ALTERNATE TRACE OUTPUT)
C14 CDP GATHER (100 FOLD INTERVAL = 12.5M)
C15 VELOCITY ANALYSIS:
C16 RADON MULTIPLE ATTENUATION
C17 D.M.O.: 100 OFFSET PLANES
C18 D.B.S.: 2 OPERATORS: 16 AND 16 MS GAP
C19 VELOCITY ANALYSIS: OMNIVELS PICKED WORKSTATION CHECKED
C20 SPHERICAL DIVERGENCE CORRECTION (FOLLOWING REMOVAL OF INITIAL GAIN)
C21 NMO CORRECTION
C22 PRE STACK SCALING (SINGLE WINDOW PER TRACE)
C23 MUTE: INNER AND OUTER TRACE.
C24 STACK:
C25 BULK STATIC CORRECTION: 10 MS
C26
C27
C28
C29
C30
C31
C32
C33
C34
C35 HE94-140 CDP 205 == SP 1001
C36 HE94-140 CDP 405 == SP 1101
C37
C38
C39
C40 CDPS 1 TO 9944 SPS 1001 TO 5873


BINARY HEADER:

job_id_number = 0
line_number = 1
reel_number = 1
traces_per_record = 200
aux_traces_per_record = 0
sample_interval = 4000
original_sample_interval = 0
samples_per_trace = 2000
original_samples_per_trace = 0
format_code = 1
CDP_fold = 100
trace_sorting_code = 0
vertical_sum_code = 0
start_sweep_frequency = 0
end_sweep_frequency = 0
sweep_length = 0
sweep_type = 0
sweep_channel_trace = 0
start_sweep_taper_length = 0
end_sweep_taper_length = 0
taper_type = 0
correlated_data_traces = 0
bin_gain_recovered = 0
ampl_recovery_method = 0
measurement_system = 0
polarity = 0
vib_polarity_code = 0



FILE INFORMATION:

segy file name = /asi/def/utilisateurs/chea/HE94/HE94-140_Raw_Stack.sgy
no template file selected
line name = HE94-140
number of traces = 9944
trace header length = 240
number of samples = 2000
start time = 0 msec
end time = 7996 msec
sample rate = 4 msec
sample format = 1 (IBM Real)
trace number extracted from byte number 1, format Integer 4-Byte
first trace number = 1
last trace number = 9944
trace number increment = 1
shotpoint number extracted from byte number 21, format Integer 4-Byte
first shotpoint = 1
last shotpoint = 9944
shotpoint increment = 1
x coordinate extracted from byte number 73, format Integer 4-Byte
first x coordinate = 0.00
last x coordinate = 0.00
y coordinate extracted from byte number 77, format Integer 4-Byte
first y coordinate = 0.00
last y coordinate = 0.00
3D line number extracted from byte number 9, format Integer 4-Byte
smallest 3D line value = 0
largest 3D line value = 0
3D trace number extracted from byte number 21, format Integer 4-Byte
smallest 3D trace value = 1
largest 3D trace value = 9944
minimum amplitude in file = -73912.6
maximum amplitude in file = 123870


********************************************************************************



TEXT HEADER:

C01 SURVEY : 1994 HE94 2D SEISMIC SURVEY
C02 LINE: HE94-142 PERMIT: WA-252/255-P DIRECTION: 123 DEGREES
C03
C04 RAW STACK
C05
C06 PROCESSING PARAMETERS: PROCESSING LENGTH(SEC): 8 SAMPLE PERIOD(MS): 4
C07
C08 TRANSCRIPTION: SEGD INTO SPT'S INTERNAL FORMAT
C09 GAIN RECOVERY
C10 INSTRUMENT DEPHASE
C11 RESAMPLE FROM 2 MS TO 4 MS
C12 FREE FORM DESIGN F-K FILTER (ACCEPT)
C13 ARRAY SIMULATION AND TRACE DECIMATION (ALTERNATE TRACE OUTPUT)
C14 CDP GATHER (100 FOLD INTERVAL = 12.5M)
C15 VELOCITY ANALYSIS:
C16 RADON MULTIPLE ATTENUATION
C17 D.M.O.: 100 OFFSET PLANES
C18 D.B.S.: 2 OPERATORS: 16 AND 16 MS GAP
C19 VELOCITY ANALYSIS: OMNIVELS PICKED WORKSTATION CHECKED
C20 SPHERICAL DIVERGENCE CORRECTION (FOLLOWING REMOVAL OF INITIAL GAIN)
C21 NMO CORRECTION
C22 PRE STACK SCALING (SINGLE WINDOW PER TRACE)
C23 MUTE: INNER AND OUTER TRACE.
C24 STACK:
C25 BULK STATIC CORRECTION: 10 MS
C26
C27
C28
C29
C30
C31
C32
C33
C34
C35 HE94-142 CDP 205 == SP 1001
C36 HE94-142 CDP 405 == SP 1101
C37
C38
C39
C40 CDPS 1 TO 7140 SPS 1001 TO 4471


BINARY HEADER:

job_id_number = 0
line_number = 2
reel_number = 1
traces_per_record = 200
aux_traces_per_record = 0
sample_interval = 4000
original_sample_interval = 0
samples_per_trace = 2000
original_samples_per_trace = 0
format_code = 1
CDP_fold = 100
trace_sorting_code = 0
vertical_sum_code = 0
start_sweep_frequency = 0
end_sweep_frequency = 0
sweep_length = 0
sweep_type = 0
sweep_channel_trace = 0
start_sweep_taper_length = 0
end_sweep_taper_length = 0
taper_type = 0
correlated_data_traces = 0
bin_gain_recovered = 0
ampl_recovery_method = 0
measurement_system = 0
polarity = 0
vib_polarity_code = 0



FILE INFORMATION:

segy file name = /asi/def/utilisateurs/chea/HE94/HE94-142_Raw_Stack.sgy
no template file selected
line name = HE94-142
number of traces = 7140
trace header length = 240
number of samples = 2000
start time = 0 msec
end time = 7996 msec
sample rate = 4 msec
sample format = 1 (IBM Real)
trace number extracted from byte number 1, format Integer 4-Byte
first trace number = 1
last trace number = 7140
trace number increment = 1
shotpoint number extracted from byte number 21, format Integer 4-Byte
first shotpoint = 1
last shotpoint = 7140
shotpoint increment = 1
x coordinate extracted from byte number 73, format Integer 4-Byte
first x coordinate = 0.00
last x coordinate = 0.00
y coordinate extracted from byte number 77, format Integer 4-Byte
first y coordinate = 0.00
last y coordinate = 0.00
3D line number extracted from byte number 9, format Integer 4-Byte
smallest 3D line value = 1001
largest 3D line value = 4471
3D trace number extracted from byte number 21, format Integer 4-Byte
smallest 3D trace value = 1
largest 3D trace value = 7140
minimum amplitude in file = -62929.9
maximum amplitude in file = 108822


********************************************************************************



TEXT HEADER:

C01 SURVEY : 1994 HE94 2D SEISMIC SURVEY
C02 LINE: HE94-144 PERMIT: WA-252/255-P DIRECTION: 304 DEGREES
C03
C04 RAW STACK
C05
C06 PROCESSING PARAMETERS: PROCESSING LENGTH(SEC): 8 SAMPLE PERIOD(MS): 4
C07
C08 TRANSCRIPTION: SEGD INTO SPT'S INTERNAL FORMAT
C09 GAIN RECOVERY
C10 INSTRUMENT DEPHASE
C11 RESAMPLE FROM 2 MS TO 4 MS
C12 FREE FORM DESIGN F-K FILTER (ACCEPT)
C13 ARRAY SIMULATION AND TRACE DECIMATION (ALTERNATE TRACE OUTPUT)
C14 CDP GATHER (100 FOLD INTERVAL = 12.5M)
C15 VELOCITY ANALYSIS:
C16 RADON MULTIPLE ATTENUATION
C17 D.M.O.: 100 OFFSET PLANES
C18 D.B.S.: 2 OPERATORS: 16 AND 16 MS GAP
C19 VELOCITY ANALYSIS: OMNIVELS PICKED WORKSTATION CHECKED
C20 SPHERICAL DIVERGENCE CORRECTION (FOLLOWING REMOVAL OF INITIAL GAIN)
C21 NMO CORRECTION
C22 PRE STACK SCALING (SINGLE WINDOW PER TRACE)
C23 MUTE: INNER AND OUTER TRACE.
C24 STACK:
C25 BULK STATIC CORRECTION: 10 MS
C26
C27
C28
C29
C30
C31
C32
C33
C34
C35 HE94-144 CDP 205 == SP 5925
C36 HE94-144 CDP 405 == SP 5825
C37
C38
C39
C40 CDPS 1 TO 10236 SPS 5925 TO 907


BINARY HEADER:

job_id_number = 0
line_number = 3
reel_number = 1
traces_per_record = 200
aux_traces_per_record = 0
sample_interval = 4000
original_sample_interval = 0
samples_per_trace = 2000
original_samples_per_trace = 0
format_code = 1
CDP_fold = 100
trace_sorting_code = 0
vertical_sum_code = 0
start_sweep_frequency = 0
end_sweep_frequency = 0
sweep_length = 0
sweep_type = 0
sweep_channel_trace = 0
start_sweep_taper_length = 0
end_sweep_taper_length = 0
taper_type = 0
correlated_data_traces = 0
bin_gain_recovered = 0
ampl_recovery_method = 0
measurement_system = 0
polarity = 0
vib_polarity_code = 0



FILE INFORMATION:

segy file name = /asi/def/utilisateurs/chea/HE94/HE94-144_Raw_Stack.sgy
no template file selected
line name = HE94-144
number of traces = 10206
trace header length = 240
number of samples = 2000
start time = 0 msec
end time = 7996 msec
sample rate = 4 msec
sample format = 1 (IBM Real)
trace number extracted from byte number 1, format Integer 4-Byte
first trace number = 1
last trace number = 10236
trace number increment = 1
shotpoint number extracted from byte number 21, format Integer 4-Byte
first shotpoint = 1
last shotpoint = 10236
shotpoint increment = 1
x coordinate extracted from byte number 73, format Integer 4-Byte
first x coordinate = 0.00
last x coordinate = 0.00
y coordinate extracted from byte number 77, format Integer 4-Byte
first y coordinate = 0.00
last y coordinate = 0.00
3D line number extracted from byte number 9, format Integer 4-Byte
smallest 3D line value = 0
largest 3D line value = 0
3D trace number extracted from byte number 21, format Integer 4-Byte
smallest 3D trace value = 1
largest 3D trace value = 10236
minimum amplitude in file = -100820
maximum amplitude in file = 122087


********************************************************************************



TEXT HEADER:

C01 SURVEY : 1994 HE94 2D SEISMIC SURVEY
C02 LINE: HE94-146 PERMIT: WA-252/255-P DIRECTION: 304 DEGREES
C03
C04 RAW STACK
C05
C06 PROCESSING PARAMETERS: PROCESSING LENGTH(SEC): 8 SAMPLE PERIOD(MS): 4
C07
C08 TRANSCRIPTION: SEGD INTO SPT'S INTERNAL FORMAT
C09 GAIN RECOVERY
C10 INSTRUMENT DEPHASE
C11 RESAMPLE FROM 2 MS TO 4 MS
C12 FREE FORM DESIGN F-K FILTER (ACCEPT)
C13 ARRAY SIMULATION AND TRACE DECIMATION (ALTERNATE TRACE OUTPUT)
C14 CDP GATHER (100 FOLD INTERVAL = 12.5M)
C15 VELOCITY ANALYSIS:
C16 RADON MULTIPLE ATTENUATION
C17 D.M.O.: 100 OFFSET PLANES
C18 D.B.S.: 2 OPERATORS: 16 AND 16 MS GAP
C19 VELOCITY ANALYSIS: OMNIVELS PICKED WORKSTATION CHECKED
C20 SPHERICAL DIVERGENCE CORRECTION (FOLLOWING REMOVAL OF INITIAL GAIN)
C21 NMO CORRECTION
C22 PRE STACK SCALING (SINGLE WINDOW PER TRACE)
C23 MUTE: INNER AND OUTER TRACE.
C24 STACK:
C25 BULK STATIC CORRECTION: 10 MS
C26
C27
C28
C29
C30
C31
C32
C33
C34
C35 HE94-146 CDP 205 == SP 4627
C36 HE94-146 CDP 405 == SP 4527
C37
C38
C39
C40 CDPS 1 TO 7640 SPS 4627 TO 907


BINARY HEADER:

job_id_number = 0
line_number = 4
reel_number = 1
traces_per_record = 200
aux_traces_per_record = 0
sample_interval = 4000
original_sample_interval = 0
samples_per_trace = 2000
original_samples_per_trace = 0
format_code = 1
CDP_fold = 100
trace_sorting_code = 0
vertical_sum_code = 0
start_sweep_frequency = 0
end_sweep_frequency = 0
sweep_length = 0
sweep_type = 0
sweep_channel_trace = 0
start_sweep_taper_length = 0
end_sweep_taper_length = 0
taper_type = 0
correlated_data_traces = 0
bin_gain_recovered = 0
ampl_recovery_method = 0
measurement_system = 0
polarity = 0
vib_polarity_code = 0



FILE INFORMATION:

segy file name = /asi/def/utilisateurs/chea/HE94/HE94-146_Raw_Stack.sgy
no template file selected
line name = HE94-146
number of traces = 7640
trace header length = 240
number of samples = 2000
start time = 0 msec
end time = 7996 msec
sample rate = 4 msec
sample format = 1 (IBM Real)
trace number extracted from byte number 1, format Integer 4-Byte
first trace number = 1
last trace number = 7640
trace number increment = 1
shotpoint number extracted from byte number 21, format Integer 4-Byte
first shotpoint = 1
last shotpoint = 7640
shotpoint increment = 1
x coordinate extracted from byte number 73, format Integer 4-Byte
first x coordinate = 0.00
last x coordinate = 0.00
y coordinate extracted from byte number 77, format Integer 4-Byte
first y coordinate = 0.00
last y coordinate = 0.00
3D line number extracted from byte number 9, format Integer 4-Byte
smallest 3D line value = 907
largest 3D line value = 4627
3D trace number extracted from byte number 21, format Integer 4-Byte
smallest 3D trace value = 1
largest 3D trace value = 7640
minimum amplitude in file = -21117
maximum amplitude in file = 26109.7


********************************************************************************



TEXT HEADER:

C01 SURVEY : 1994 HE94 2D SEISMIC SURVEY
C02 LINE: HE94-148 PERMIT: WA-252/255-P DIRECTION: 303 DEGREES
C03
C04 RAW STACK
C05
C06 PROCESSING PARAMETERS: PROCESSING LENGTH(SEC): 8 SAMPLE PERIOD(MS): 4
C07
C08 TRANSCRIPTION: SEGD INTO SPT'S INTERNAL FORMAT
C09 GAIN RECOVERY
C10 INSTRUMENT DEPHASE
C11 RESAMPLE FROM 2 MS TO 4 MS
C12 FREE FORM DESIGN F-K FILTER (ACCEPT)
C13 ARRAY SIMULATION AND TRACE DECIMATION (ALTERNATE TRACE OUTPUT)
C14 CDP GATHER (100 FOLD INTERVAL = 12.5M)
C15 VELOCITY ANALYSIS:
C16 RADON MULTIPLE ATTENUATION
C17 D.M.O.: 100 OFFSET PLANES
C18 D.B.S.: 2 OPERATORS: 16 AND 16 MS GAP
C19 VELOCITY ANALYSIS: OMNIVELS PICKED WORKSTATION CHECKED
C20 SPHERICAL DIVERGENCE CORRECTION (FOLLOWING REMOVAL OF INITIAL GAIN)
C21 NMO CORRECTION
C22 PRE STACK SCALING (SINGLE WINDOW PER TRACE)
C23 MUTE: INNER AND OUTER TRACE.
C24 STACK:
C25 BULK STATIC CORRECTION: 10 MS
C26
C27
C28
C29
C30
C31
C32
C33
C34
C35 HE94-148 CDP 205 == SP 3143
C36 HE94-148 CDP 405 == SP 3043
C37
C38
C39
C40 CDPS 1 TO 4672 SPS 3143 TO 907


BINARY HEADER:

job_id_number = 0
line_number = 5
reel_number = 1
traces_per_record = 200
aux_traces_per_record = 0
sample_interval = 4000
original_sample_interval = 0
samples_per_trace = 2000
original_samples_per_trace = 0
format_code = 1
CDP_fold = 100
trace_sorting_code = 0
vertical_sum_code = 0
start_sweep_frequency = 0
end_sweep_frequency = 0
sweep_length = 0
sweep_type = 0
sweep_channel_trace = 0
start_sweep_taper_length = 0
end_sweep_taper_length = 0
taper_type = 0
correlated_data_traces = 0
bin_gain_recovered = 0
ampl_recovery_method = 0
measurement_system = 0
polarity = 0
vib_polarity_code = 0



FILE INFORMATION:

segy file name = /asi/def/utilisateurs/chea/HE94/HE94-148_Raw_Stack.sgy
no template file selected
line name = HE94-148
number of traces = 4672
trace header length = 240
number of samples = 2000
start time = 0 msec
end time = 7996 msec
sample rate = 4 msec
sample format = 1 (IBM Real)
trace number extracted from byte number 1, format Integer 4-Byte
first trace number = 1
last trace number = 4672
trace number increment = 1
shotpoint number extracted from byte number 21, format Integer 4-Byte
first shotpoint = 1
last shotpoint = 4672
shotpoint increment = 1
x coordinate extracted from byte number 73, format Integer 4-Byte
first x coordinate = 0.00
last x coordinate = 0.00
y coordinate extracted from byte number 77, format Integer 4-Byte
first y coordinate = 0.00
last y coordinate = 0.00
3D line number extracted from byte number 9, format Integer 4-Byte
smallest 3D line value = 0
largest 3D line value = 3143
3D trace number extracted from byte number 21, format Integer 4-Byte
smallest 3D trace value = 1
largest 3D trace value = 4672
minimum amplitude in file = -58102.5
maximum amplitude in file = 95030.1


********************************************************************************

 
CaWiki's suggestion worked like a treat, thanks!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top