使用python提取/读取Google colab jupyter笔记本中.gz文件的内容

时间:2020-10-15 08:24:22

标签: python jupyter-notebook gzip google-colaboratory colab

我是使用google colab的初学者,但是我没有找到读取.gz文件内容的方法。 我尝试运行以下代码:

    full_path = /content/gdrive/My Drive/7ParkData.zip/2016/09/03/00/US/CR/1d38180c9c6ab36c/part-00001-00016.gz

    with gzip.open(full_path,'rt', encoding = 'utf8')
    !gunzip full_path -d "/content/gdrive/My Drive"
    !gz xvf full_path -d "/content/gdrive/My Drive"
    shutil.unpack_archive(full_path, "/content/gdrive/My Drive/")

“ full_path”是动态的,因为其意图是读取多个.gz文件并根据需要存储内容。 “ gzip.open”代码在我的本地jupyter笔记本中运行良好。

0 个答案:

没有答案