Skip to content Skip to sidebar Skip to footer

How To Read Data From Google Storage Cloud To Google Cloud Datalab

I have a few CSV files storing in Google storage and I want to read those into Google datalab. So far, I have no idea how to do it. I found this and followed the first answer but d

Solution 1:

If you subtract one of the % symbols it should work. Minimal example:

import google.datalab.storage as storage
import pandas as pd
from io import BytesIO

mybucket = storage.Bucket('BUCKET_NAME')
data_csv = mybucket.object('data.csv')

uri = data_csv.uri
%gcs read --object $uri --variable data

df = pd.read_csv(BytesIO(data))
df.head()

Post a Comment for "How To Read Data From Google Storage Cloud To Google Cloud Datalab"