open, mode='rb', file_size=None, opener=None)[source] [edit on github]

Read or write several files as if they were one contiguous one.

fileslist, tuple, or other iterable of str, filehandle

Contains the names of the underlying files that should be combined, ordered in time. 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’).

file_sizeint, optional

For writing, the maximum size of a file, beyond which a new file should be opened. Default: None, which means it is unlimited and only a single file will be written.

openercallable, optional

Function to open a single file (default:


The returned reader/writer will have a memmap method with which part of the files can be mapped to memory (like with memmap), as long as those parts do not span files (and the underlying files are regular ones). For writing, this requires opening in read-write mode (i.e., ‘w+b’).

Methods other than read, write, seek, tell, and close are tried on the underlying file. This implies, e.g., readline is possible, though the line cannot span multiple files.

The reader assumes the sequence of files is contiguous in time, ie. with no gaps in the data.