Filepath Or Buffer

Contains functions and classes for handling filepaths and buffers.

dataprofiler.data_readers.filepath_or_buffer.is_stream_buffer(filepath_or_buffer: Any) typing_extensions.TypeGuard[Union[_io.StringIO, _io.BytesIO]]

Determine 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: Union[str, _io.StringIO, _io.BytesIO], open_method: str = 'r', encoding: Optional[str] = None, seek_offset: Optional[int] = None, seek_whence: int = 0)

Bases: object

FileOrBufferHandler class to read a filepath or buffer in.

Always returns a readable buffer.

Initialize 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