SequentialFileReader

class baseband.helpers.sequentialfile.SequentialFileReader(files, mode='rb', opener=None)[source] [edit on github]

Bases: SequentialFileBase

Read several files as if they were one contiguous one.

Parameters:
fileslist, tuple, or other iterable of str, filehandle

The contains the names of the underlying files that should be combined. If not a list or tuple, it should allow indexing with positive indices, and raise IndexError if these are out of range.

modestr, optional

The mode with which the files should be opened (default: ‘rb’)

openercallable, optional

Function to open a single file (default: io.open).

Attributes Summary

file_nr

file_size

Size of the underlying file currently open for reading.

size

Size of all underlying files combined.

Methods Summary

close()

Close the currently open local file, and therewith the set.

memmap([dtype, mode, offset, shape, order])

Map part of the file in memory.

read([count])

Read and return up to n bytes.

seek(offset[, whence])

Change stream position.

tell()

Return the current stream position.

Attributes Documentation

file_nr = None
file_size

Size of the underlying file currently open for reading.

size

Size of all underlying files combined.

Methods Documentation

close() [edit on github]

Close the currently open local file, and therewith the set.

memmap(dtype=<class 'numpy.uint8'>, mode=None, offset=None, shape=None, order='C') [edit on github]

Map part of the file in memory.

Note that the map cannnot span multiple underlying files. Parameters are as for memmap.

read(count=None)[source] [edit on github]

Read and return up to n bytes.

If the argument is omitted, None, or negative, reads and returns all data until EOF.

If the argument is positive, and the underlying raw stream is not ‘interactive’, multiple raw reads may be issued to satisfy the byte count (unless EOF is reached first). But for interactive raw streams (as well as sockets and pipes), at most one raw read will be issued, and a short result does not imply that EOF is imminent.

Returns an empty bytes object on EOF.

Returns None if the underlying raw stream was open in non-blocking mode and no data is available at the moment.

seek(offset, whence=0)[source] [edit on github]

Change stream position.

Change the stream position to the given byte offset. The offset is interpreted relative to the position indicated by whence. Values for whence are:

  • 0 – start of stream (the default); offset should be zero or positive

  • 1 – current stream position; offset may be negative

  • 2 – end of stream; offset is usually negative

Return the new absolute position.

tell() [edit on github]

Return the current stream position.