#NEWLINE# def searchFile( filename , atom , verbose , item ) : #NEWLINE# #INDENT# fileh = open_file ( filename , mode = 'r' ) #NEWLINE# rowsread = 0 #NEWLINE# uncomprBytes = 0 #NEWLINE# table = fileh . root . table #NEWLINE# if ( atom == 'int' ) : #NEWLINE# #INDENT# idxcol = table . cols . var2 . index #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( atom == 'float' ) : #NEWLINE# #INDENT# idxcol = table . cols . var3 . index #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'Unsuported atom value' ) #NEWLINE# #UNINDENT# #UNINDENT# print ( 'Searching' , table , '...' ) #NEWLINE# if verbose : #NEWLINE# #INDENT# print ( 'Chunk size:' , idxcol . sorted . chunksize ) #NEWLINE# print ( 'Number of elements per slice:' , idxcol . sorted . nelemslice ) #NEWLINE# print ( 'Slice number in' , table . _v_pathname , ':' , idxcol . sorted . nrows ) #NEWLINE# #UNINDENT# ( positions , niter ) = idxcol . search ( item ) #NEWLINE# if verbose : #NEWLINE# #INDENT# print ( 'Positions for item' , item , '==>' , positions ) #NEWLINE# print ( 'Total iterations in search:' , niter ) #NEWLINE# #UNINDENT# rowsread += table . nrows #NEWLINE# uncomprBytes += ( ( idxcol . sorted . chunksize * niter ) * idxcol . sorted . itemsize ) #NEWLINE# results = table . read ( coords = positions ) #NEWLINE# print ( 'results length:' , len ( results ) ) #NEWLINE# if verbose : #NEWLINE# #INDENT# print ( 'Values that fullfill the conditions:' ) #NEWLINE# print ( results ) #NEWLINE# #UNINDENT# fileh . close ( ) #NEWLINE# return ( rowsread , uncomprBytes , niter )