#NEWLINE# @ infer_types . register ( 'rows' ) #NEWLINE# def _( ctx , obj , date_format = None ) : #NEWLINE# #INDENT# rownum = 0 #NEWLINE# probes = defaultdict ( set ) #NEWLINE# for row in obj : #NEWLINE# #INDENT# rownum += 1 #NEWLINE# for ( i , value ) in enumerate ( row ) : #NEWLINE# #INDENT# probes [ i ] . add ( guess_type ( value , date_format ) ) #NEWLINE# #UNINDENT# #UNINDENT# keys = list ( probes . keys ( ) ) #NEWLINE# keys . sort ( ) #NEWLINE# types = [ probes [ key ] for key in keys ] #NEWLINE# if ( field_names and ( len ( types ) != len ( field_names ) ) ) : #NEWLINE# #INDENT# raise Exception ( 'Number of detected fields differs from number of fields specified in the header row' ) #NEWLINE# #UNINDENT# out_fields = FieldList ( ) #NEWLINE# fields = FieldList ( Field ( 'field' , 'string' ) , Field ( 'type' , 'string' ) ) #NEWLINE# result = [ ] #NEWLINE# for ( name , types ) in zip ( field_names , types ) : #NEWLINE# #INDENT# if ( 'string' in types ) : #NEWLINE# #INDENT# t = 'string' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'integer' in types ) : #NEWLINE# #INDENT# t = 'integer' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'float' in types ) : #NEWLINE# #INDENT# t = 'float' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'date' in types ) : #NEWLINE# #INDENT# t = 'date' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# t = 'string' #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# result . append ( ( name , t ) ) #NEWLINE# #UNINDENT# return IterableDataSource ( result , out_fields )