gpt4 book ai didi

python-3.x - 从桶谷歌云加载数据

转载 作者:行者123 更新时间:2023-12-05 08:08:16 24 4
gpt4 key购买 nike

这是一个从谷歌云桶加载数据的函数。

action_dataset_folder_path = 'action-data-set'
zip_path = 'actions.zip'
url='http://console.cloud.google.com/storage/browser/actions'

class LoadProgress(tqdm):
last_block = 0

def hook(self, block_num=1, block_size=1, total_size=None):
self.total = total_size
self.update((block_num - self.last_block) * block_size)
self.last_block = block_num

if not isfile(zip_path):
with LoadProgress(unit='B', unit_scale=True, miniters=1, desc='actions-Dataset') as pbar:
urlretrieve(
url,
zip_path,
pbar.hook)
if not isdir(action_dataset_folder_path):
with tarfile.open(zip_path) as tar:
tar.extractall()
tar.close()
print('All done ...!')

文件下载为空文件,大小为 73.7KB!我不明白!似乎一切都很好。

最佳答案

这是来自谷歌云站点的代码:python-code

    from gcloud import storage
def download_blob(bucket_name, source_blob_name, destination_file_name):
"""Downloads a blob from the bucket."""
storage_client = storage.Client()
bucket = storage_client.get_bucket(bucket_name)
blob = bucket.blob(source_blob_name)

blob.download_to_filename(destination_file_name)

print('Blob {} downloaded to {}.'.format(
source_blob_name,
destination_file_name))
download_blob("datset","actions", "dataset")

关于python-3.x - 从桶谷歌云加载数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50383125/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com