class documentation

class LocalFileReader(FileReader):

Constructor: LocalFileReader()

View In Hierarchy

Local file system implementation of FileReader.

This class provides functionality to:

  • Read files from the local filesystem
  • Load file contents into pandas DataFrames
  • List directory contents
  • Execute shell commands locally
Static Method get_local_file_size Returns the size of a local file in bytes.
Method __init__ Initializes an instance of LocalFileReader.
Method listdir Lists directories and files in a given local directory path.
Method run_cmd Executes a shell command locally and returns its output.
Method _read_file_content Smart file content reader.
Method _read_vcf_as_dataframe Undocumented

Inherited from FileReader:

Method __del__ Destructor to clean up temporary files if clean_on_destruction is enabled.
Method clean_tmp_files Deletes a temporary file if it exists.
Method decode_content_by_type Decodes content based on file type, returning a DataFrame or raw string.
Method download_remote_file Abstract method. Downloads a file from a remote location.
Method get_file_extension Extracts the file extension from a given path.
Method get_file_size Placeholder to get file size.
Method is_remote Checks if the reader is set to remote mode.
Method isfile Checks if a given path exists and is a file.
Method load_h5ad_file Placeholder for remote/local logic in loading H5AD files.
Method read_file Unified file reader for local or remote paths. :param path: File path. :param type: Optional file type override (generic types: pdf, image, text, csv, zip). :param as_dataframe: Whether to parse into a DataFrame...
Method read_file_into_df File reader into a dataframe for local and remote paths :param path: File path. :param type: Optional file type override (generic types: pdf, image, text, csv, zip). :param as_dataframe: Force a parsing into a DataFrame...
Method read_h5ad Reads an H5AD file using `anndatareader`.
Method read_vcf_file_into_df Reads a VCF (Variant Call Format) file using `pysam`.
Method set_clean_on_dest Sets the `clean_on_destruction` flag.
Method write_to_remote_file Abstract method. Writes data to a remote file.
Instance Variable clean_on_destruction Undocumented
Instance Variable files_to_clean Undocumented
Instance Variable remote Undocumented
Method _is_auto_dataframe_type Undocumented
Method _is_binary_type Undocumented
Method _is_text_type Undocumented
@staticmethod
def get_local_file_size(file_path):

Returns the size of a local file in bytes.

:param file_path: Path to the file. :type file_path: str

:return: File size in bytes or None if the file doesn't exist. :rtype: int | None

def __init__(self):

Initializes an instance of LocalFileReader.

def listdir(self, path):

Lists directories and files in a given local directory path.

:param path: Directory path to list contents from. :type path: str

:return: A tuple containing a list of subdirectories and a list of files. :rtype: tuple[list[str], list[str]]

def run_cmd(self, command):

Executes a shell command locally and returns its output.

:param command: Command string to execute. :type command: str

:return: Dictionary with 'output' and 'err' keys. :rtype: dict

def _read_file_content(self, path, mode, is_text):

Smart file content reader.

  • For text files: reads and returns content.
  • For non-text (binary) files or for csv files: returns path to be handled later by decode_content_by_type.
def _read_vcf_as_dataframe(self, path):

Undocumented