我试图打开gcs bucket中的csv文件来读取内容并在BigQuery中相应地处理数据。我能列出csv的存在在桶,但不能打开它。我的代码如下:
with cloudstorage.open(bucket_name/gs_file,"r+") as csvFile:
reader = csv.reader(iter(csvFile.readline,''), delimiter = '|')
csvfilearray = next(reader)
print (csvfilearray)
获取以下错误:
NameError: name 'cloudstorage' is not defined
导入的云存储如下:
^{pr2}$并再次尝试使用gcs.open
,但仍然错误:
File "./GCS_Connection_Test.py", line 10, in <module>
import cloudstorage as gcs
ImportError: No module named cloudstorage
有谁能帮忙打开GCS上的文件进行处理吗。在
根据您的
app.yaml
文件,您处于灵活的环境中。在您使用了
GoogleAppEngineCloudStorageClient
,这是一个标准的环境库(就像appengine-gcs-client
),您需要使用google-cloud-storage
库,请参阅Using Cloud Storage指南中的Edit project configuration and install dependencies部分,这是您需要遵循的。在您还遵循了安装库的标准环境说明,您需要使用灵活的环境说明,请参见Using Python Libraries。在
一般注意:在doc页面url中查找
docs/flexible
vsdocs/standard
字符串,以区分它们(或者在文档左侧导航栏顶部附近显示的环境类型,您可能需要向上滚动才能看到它)相关问题 更多 >
编程相关推荐