#! /usr/bin/env python # OM, 14 Aug 2006 from string import split import sys File = open('0120_linje5.log.dat') SP_start = 160 # 'SP' means Shotpoint SP_end = 1060 Current_Line = 0 for Line in File: # Loop through all lines in file Current_Line += 1 if Line[0] == '0': # Data lines assumed to start with '0' (leading zeros of Shotpoint number) s = Line.split() # s will hold array of all parameters on line, 's[0]' is the first element try: ShotPoint = int(s[0]) # Convert from ASCII text to integer, report error and exit except: print 'Error in line:', Current_Line sys.exit(0) Easting = s[2] Northing = s[3] Depth = s[10] if (SP_start <= ShotPoint <= SP_end): print ShotPoint, Easting, Northing, Depth