How to read a csv file on google cloud storage using python on Jupyter Notebook?

1,031 views
Skip to first unread message

Hiral Mehta

unread,
Aug 18, 2016, 5:10:58 PM8/18/16
to Google App Engine
Hi,

I created a Cluster on Compute Engine and running Juoyter Notebook service on that. 
I then used python to run a simple machine learning program but stuck at a very initial phase.

Unable to read csv file uploaded on google storage into a simple python program. The error and the sample program are attached.
Looking for inputs and would appreciate your help.

Thanks,
Hiral Mehta
CloudStorageError.png

Alex Martelli

unread,
Aug 18, 2016, 6:02:13 PM8/18/16
to google-a...@googlegroups.com
This question is not related to google-appengine and thus it's inappropriate on this group. Rather, ask on the gce-discussion group, or on stackoverflow.com with the right tags (python jupyter google-compute-engine google-cloud-storage).

Anyway, the issue is that Python's `open` only supports actual filesystems and there is no `gs:` one (just as the error msg says, there IS no such file or directory!). Rather, you'll want to e.g `import urllib` and use `urllib.urlopen` on the appropriate google cloud storage URL to obtain the file-like object to pass to `csv.reader`.


Alex


--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscribe@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/f1ad0a52-1257-4be0-95a7-3e6eaa7a9a2b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages