#NEWLINE# @ discover . register ( CSV ) #NEWLINE# def discover_csv( c , nrows = 1000 , **kwargs ) : #NEWLINE# #INDENT# df = csv_to_dataframe ( c , nrows = nrows , ** kwargs ) #NEWLINE# df = coerce_datetimes ( df ) #NEWLINE# columns = [ ( str ( c ) if ( not isinstance ( c , ( str , unicode ) ) ) else c ) for c in df . columns ] #NEWLINE# df . columns = [ c . strip ( ) for c in columns ] #NEWLINE# for col in df . columns : #NEWLINE# #INDENT# if ( not df [ col ] . count ( ) ) : #NEWLINE# #INDENT# df [ col ] = None #NEWLINE# #UNINDENT# #UNINDENT# measure = discover ( df ) . measure #NEWLINE# measure = Record ( [ [ name , ( Option ( typ ) if ( df [ name ] . isnull ( ) . any ( ) and ( not isinstance ( typ , Option ) ) ) else typ ) ] for ( name , typ ) in zip ( measure . names , measure . types ) ] ) #NEWLINE# return ( datashape . var * measure )