#NEWLINE# def _csv_to_dataframe( c , dshape = None , chunksize = None , **kwargs ) : #NEWLINE# #INDENT# header = { #NEWLINE# #INDENT# False : None , #NEWLINE# True : 0 , #NEWLINE# #UNINDENT# } . get ( kwargs . pop ( 'has_header' , c . has_header ) , 'infer' ) #NEWLINE# sep = kwargs . pop ( 'sep' , kwargs . pop ( 'delimiter' , c . dialect . get ( 'delimiter' , ',' ) ) ) #NEWLINE# encoding = kwargs . pop ( 'encoding' , c . encoding ) #NEWLINE# if dshape : #NEWLINE# #INDENT# ( dtypes , parse_dates ) = dshape_to_pandas ( dshape ) #NEWLINE# if isrecord ( dshape . measure ) : #NEWLINE# #INDENT# names = kwargs . get ( 'names' , dshape . measure . names ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# names = kwargs . get ( 'names' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# dtypes = parse_dates = names = None #NEWLINE# #UNINDENT# usecols = kwargs . pop ( 'usecols' , None ) #NEWLINE# if ( parse_dates and usecols ) : #NEWLINE# #INDENT# parse_dates = [ col for col in parse_dates if ( col in usecols ) ] #NEWLINE# #UNINDENT# compression = kwargs . pop ( 'compression' , { #NEWLINE# #INDENT# 'gz' : 'gzip' , #NEWLINE# 'bz2' : 'bz2' , #NEWLINE# #UNINDENT# } . get ( ext ( c . path ) ) ) #NEWLINE# if names : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# found_names = pd . read_csv ( c . path , encoding = encoding , compression = compression , nrows = 1 ) #NEWLINE# #UNINDENT# except StopIteration : #NEWLINE# #INDENT# found_names = pd . read_csv ( c . path , encoding = encoding , compression = compression ) #NEWLINE# #UNINDENT# #UNINDENT# if ( names and ( header == 'infer' ) ) : #NEWLINE# #INDENT# if ( [ n . strip ( ) for n in found_names ] == [ n . strip ( ) for n in names ] ) : #NEWLINE# #INDENT# header = 0 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( all ( ( re . match ( '^\\s*\\D\\w*\\s*$' , n ) for n in found_names ) ) and ( not all ( ( ( dt == datashape . string ) for dt in dshape . measure . types ) ) ) ) : #NEWLINE# #INDENT# header = 0 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# header = None #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# kwargs = keyfilter ( keywords ( pd . read_csv ) . __contains__ , kwargs ) #NEWLINE# return pd . read_csv ( c . path , header = header , sep = sep , encoding = encoding , dtype = dtypes , parse_dates = parse_dates , names = names , compression = compression , chunksize = chunksize , usecols = usecols , ** kwargs )