def pandas_read_text(reader, b, header, kwargs, dtypes=None, columns=None, write_header=True, enforce=False):
 bio = BytesIO()
 if (write_header and (not b.startswith(header.rstrip()))):
  bio.write(header)
 bio.write(b)
 bio.seek(0)
 df = reader(bio, **kwargs)
 if dtypes:
  coerce_dtypes(df, dtypes)
 if (enforce and columns and (list(df.columns) != list(columns))):
  raise ValueError('Columns do not match', df.columns, columns)
 elif columns:
  df.columns = columns
 return df

def pandas_read_text ( reader , b , header , kwargs , dtypes = None , columns = None , write_header = True , enforce = False ) : bio = BytesIO ( ) if ( write_header and ( not b . startswith ( header . rstrip ( ) ) ) ) : bio . write ( header ) bio . write ( b ) bio . seek ( 0 ) df = reader ( bio , ** kwargs ) if dtypes : coerce_dtypes ( df , dtypes ) if ( enforce and columns and ( list ( df . columns ) != list ( columns ) ) ) : raise ValueError ( 'Columns do not match' , df . columns , columns ) elif columns : df . columns = columns return df
convert a block of bytes to a pandas dataframe parameters reader : callable pd .