Skip to content

Helper class to read content spread over multiple files as if it was one file

License

Notifications You must be signed in to change notification settings

gncv/multifile-reader

Repository files navigation

MultiFile Reader

Supported Python versions: 2.7+, 3.7+

This module implements a helper class to quickly read multiple files in sequence and treat them as if they are one file.

Especially useful in reading big files, which are split into multiple parts, such as FASTQ files.

Files are open and read in binary mode.

Installation

pip install multifile-reader

Example Usage

Then in your code:

from multifile_reader import MultiFileReader

with MultiFileReader(files) as file_obj:
    content_binary = file_obj.read()

files can be list or tuple.

Or to read big files in chunks:

from multifile_reader import MultiFileReader

with MultiFileReader(files) as file_obj:
    chunk = file_obj.read(1)
    content_binary = chunk
    while chunk:
        chunk = file_obj.read(1)
        content_binary += chunk
        # or do something else with the chunk

Contributors

Gencove

About

Helper class to read content spread over multiple files as if it was one file

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages