【发布时间】:2016-06-03 09:13:34
【问题描述】:
我有一个 zip 文件,其中包含一个相对较大的数据集 (1Gb),存储在 Google Cloud Storage 实例中的一个 zip 文件中。
我需要使用托管在 Google Cloud Datalab 中的笔记本来访问该文件以及其中包含的数据。我该怎么办?
谢谢。
【问题讨论】:
标签: google-cloud-storage google-cloud-datalab
我有一个 zip 文件,其中包含一个相对较大的数据集 (1Gb),存储在 Google Cloud Storage 实例中的一个 zip 文件中。
我需要使用托管在 Google Cloud Datalab 中的笔记本来访问该文件以及其中包含的数据。我该怎么办?
谢谢。
【问题讨论】:
标签: google-cloud-storage google-cloud-datalab
您可以尝试以下方法吗?
import pandas as pd
# Path to the object in Google Cloud Storage that you want to copy
sample_gcs_object = 'gs://path-to-gcs/Hello.txt.zip'
# Copy the file from Google Cloud Storage to Datalab
!gsutil cp $sample_gcs_object 'Hello.txt.zip'
# Unzip the file
!unzip 'Hello.txt.zip'
# Read the file into a pandas DataFrame
pandas_dataframe = pd.read_csv('Hello.txt')
【讨论】: