This is the notebook that illustrates using gcloud datastore for section 3.4. notice that the authentication has already been established when we install gs
from gcloud import storage
client = storage.Client()
from gcloud import datastore
clientds = datastore.Client()
import csv
bucket = client.bucket('book-datacont')
key = clientds.key('book-table')
with open('path to your csv file\experiments.csv', 'rb') as csvfile:
csvf = csv.reader(csvfile, delimiter=',', quotechar='|')
for item in csvf:
print item
blob = bucket.blob(item[3])
data = open("path-to-your-datafiles\datafiles\\"+item[3], 'rb')
blob.upload_from_file(data)
blob.make_public()
url = "https://storage.googleapis.com/book-datacont/"+item[3]
entity = datastore.Entity(key=key)
entity['experiment-name'] = item[0]
entity['experiment-id'] = item[1]
entity['date'] = item[2]
entity['description'] = item[4]
entity['url'] = url
clientds.put(entity)
query = clientds.query(kind=u'book-table')
query.add_filter(u'experiment-name', '=', 'experiment1')
results = list(query.fetch())
urls = [result['url'] for result in results]
urls