#NEWLINE# def __init__( self , form ) : #NEWLINE# #INDENT# self . form = form #NEWLINE# self . regex_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . column_locations_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# form_file = ( '%s/%s.csv' % ( CSV_FILE_DIRECTORY , form ) ) #NEWLINE# form_reader = csv . reader ( open ( row , 'rU' ) ) #NEWLINE# header = form_reader . next ( ) #NEWLINE# for ( i , regex ) in enumerate ( header ) : #NEWLINE# #INDENT# if ( ( regex != '' ) and ( regex != 'canonical' ) ) : #NEWLINE# #INDENT# self . regex_dict [ regex ] = i #NEWLINE# #UNINDENT# #UNINDENT# body_rows = [ ] #NEWLINE# for row in form_reader : #NEWLINE# #INDENT# body_rows . append ( row ) #NEWLINE# #UNINDENT# for regex in self . regex_dict : #NEWLINE# #INDENT# this_column_locations = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for row in body_rows : #NEWLINE# #INDENT# if ( len ( row ) > self . regex_dict [ regex ] ) : #NEWLINE# #INDENT# if ( row [ self . regex_dict [ regex ] ] != '' ) : #NEWLINE# #INDENT# this_column_locations [ row [ 0 ] ] = ( int ( row [ self . regex_dict [ regex ] ] ) - 1 ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . column_locations_dict [ regex ] = this_column_locations