0
我想了解如何將多行csv文件寫入谷歌雲存儲。我只是不繼documentation將csv寫入谷歌雲存儲
關閉到這裏: Unable to read csv file uploaded on google cloud storage bucket
例子:
from google.cloud import storage
from oauth2client.client import GoogleCredentials
import os
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = "<pathtomycredentials>"
a=[1,2,3]
b=['a','b','c']
storage_client = storage.Client()
bucket = storage_client.get_bucket("<mybucketname>")
blob=bucket.blob("Hummingbirds/trainingdata.csv")
for eachrow in range(3):
blob.upload_from_string(str(a[eachrow]) + "," + str(b[eachrow]))
,讓你在谷歌雲存儲一行
3,c
顯然這每次打開一個新文件並寫下該行。
好的,如何添加一個新的行界限?
for eachrow in range(3):
blob.upload_from_string(str(a[eachrow]) + "," + str(b[eachrow]) + "\n")
加了換行符,但又從頭開始寫。
有人可以說明這個方法是什麼嗎?我可以將我所有的行合併成一個字符串,或者寫一個臨時文件,但這看起來非常難看。
也許與文件打開?