Filepath Or Buffer

dataprofiler.data_readers.filepath_or_buffer.is_stream_buffer(filepath_or_buffer)

Determines whether a given argument is a filepath or buffer.

Parameters

filepath_or_buffer (str) – path to the file or buffer

Returns

true if string is a buffer or false if string is a filepath

Return type

boolean

class dataprofiler.data_readers.filepath_or_buffer.FileOrBufferHandler(filepath_or_buffer, open_method='r', encoding=None, seek_offset=None, seek_whence=0)

Bases: object

FileOrBufferHandler class to read a filepath or buffer in and always return a readable buffer.

Context manager class used for inputting a file or buffer and returning a structure that is always a buffer.

Parameters
  • filepath_or_buffer (Union[str, StringIO, BytesIO]) – path to the file being loaded or buffer

  • open_method (string) – value describes the mode the file is opened in

  • seek_offset (int) – offset from start of the stream

Returns

TextIOBase or BufferedIOBase class/subclass