Handling of compressed files is offered by the BZ2File class.
filename[, mode[, buffering[, compresslevel]]]) |
'r'
or 'w'
, for reading
(default) or writing. When opened for writing, the file will be created if
it doesn't exist, and truncated otherwise. If buffering is given,
0
means unbuffered, and larger numbers specify the buffer size;
the default is 0
. If
compresslevel is given, it must be a number between 1
and
9
; the default is 9
.
Add a "U" to mode to open the file for input with universal newline
support. Any line ending in the input file will be seen as a
"\n" in Python. Also, a file so opened gains the
attribute newlines; the value for this attribute is one of
None
(no newline read yet), '\r'
, '\n'
,
'\r\n'
or a tuple containing all the newline types
seen. Universal newlines are available only when reading.
Instances support iteration in the same way as normal file
instances.
) |
[size]) |
[size]) |
[size]) |
) |
for line in file
instead.
offset[, whence]) |
0
(offset from start of file,
offset should be >= 0
); other values are 1
(move relative to
current position, positive or negative), and 2
(move relative to end
of file, usually negative, although many platforms allow seeking beyond
the end of a file).
Note that seeking of bz2 files is emulated, and depending on the parameters the operation may be extremely slow.
) |
data) |
sequence_of_strings) |
See About this document... for information on suggesting changes.