Skip to content

Expose contents of an entry as a filelike object #144

Description

@mskiptr

The data I'm working with is provided as a RAR containing several NPY files. To avoid complex external pre-processing and pointless temporary files, I was trying to keep everything in Python. That is fully possible as Numpy can be given not just a file path but any file-like object. Doing the plumbing manually turns out to be relatively straightforward:

def extract_into_memory(archive_entry):
    import io
    contents = io.BytesIO()
    for block in archive_entry.get_blocks():
        contents.write(block)
    contents.seek(0)
    return contents

But maybe it would be worthwhile to include a similar helper function as part of this library?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions