问题陈述:有一些桶的。需要将数据从这些桶中导入到:
任何参考代码,以便能够在这些情况下,将不胜感激。亲切的问候
发布于 2022-10-05 18:43:58
本地木星实例:首先使用gcloud / auth登录对本地env进行身份验证,然后使用古提尔将内容复制到本地env。
# Authenticate with your account
!gcloud auth login --no-browser
# Copy from your bucket to local path (note -r is for recursive call)
!gsutil cp -r gs://BUCKET/DIR_PATH ./TARGET_DIR Colab :首先对Colab会话进行身份验证以访问云APIs.Then,您可以使用gsutil将内容复制到本地env。
# Authenticate with your account
from google.colab import auth as google_auth
google_auth.authenticate_user()
# Copy from your bucket to local path (note -r is for recursive call)
!gsutil cp -r gs://BUCKET/DIR_PATH ./TARGET_DIRJupyterLab笔记本电脑在顶点AI:您的env已经通过认证。使用gsutil将内容复制到本地env。
# Copy from your bucket to local path (note -r is for recursive call)
!gsutil cp -r gs://BUCKET/DIR_PATH ./TARGET_DIR您还可以使用云存储客户端库通过Python直接访问Google中的文件。您需要首先对您的环境进行身份验证,如前所述。
# Imports the Google Cloud client library
from google.cloud import storage
# Instantiates a client
storage_client = storage.Client()
# The name for the new bucket
bucket_name = "my-new-bucket"
# Creates the new bucket
bucket = storage_client.create_bucket(bucket_name)
print(f"Bucket {bucket.name} created.")https://stackoverflow.com/questions/68419081
复制相似问题