def decompress_bz2(bz2_path, new_path):
"""
This function decompresses a .bz2 file
:param bz2_path:
:param new_path:
:return:
"""
# Decompress, create decompressed new file
with open(new_path, 'wb') as new_file, bz2.BZ2File(bz2_path, 'rb') as file:
for data in iter(lambda: file.read(100 * 1024), b''):
new_file.write(data)
# -----------------------------------------------------------------
## This function opens a text file in read-only mode. If a file exists at the specified path, it is simply opened.
# Otherwise, the function looks for a ZIP archive with the same name as the directory in which the file would have
# resided, but with the ".zip" extension added, and it attempts to open a file with the same name from the archive.
# In both cases, the function returns a read-only file-like object that offers sequential access, i.e. it provides
# only the following methods: read(), readline(), readlines(), \_\_iter\_\_(), next().
#
评论列表
文章目录