【问题标题】:Using binary file stored in storage account from python script从 python 脚本使用存储在存储帐户中的二进制文件
【发布时间】:2018-11-01 08:44:27
【问题描述】:

我正在尝试使用 java 从我的 Web 应用程序运行 python script(脚本驻留在我的应用程序文件系统中的 \wwwroot 目录中),脚本使用 binary file (g.bin) ,二进制文件很大(3.5+ GB),所以我将它存储在一个存储帐户(文件服务)中,现在我想使用在bin文件中找到的数据,如何使用我的脚本打开文件? python script 应该使用什么路径以及如何打开它?

【问题讨论】:

    标签: python azure azure-storage


    【解决方案1】:

    需要使用azure-storage python SDK,需要的模块是azure.storage.file.fileservice

    首先初始化FileService

    f = FileService(account_name=None, account_
                    key=None, sas_token=None,
                    protocol=’https’, endpoint_
                    suffix=’core.windows.net’,
                    request_session=None, connection_
                    string=None)
    

    然后您需要使用fileservice.get_file_to_stream 方法将文件下载到流中。

    f.get_file_to_stream(share_name, directory_name, file_name, stream, start_range=None, end_range=None, validate_content=False, progress_callback=None, max_connections=2, timeout=None, snapshot=None)
    

    试试看。如果您无法使其正常工作,请根据您的尝试更新您的问题,我们很乐意为您提供帮助。

    【讨论】:

    • 谢谢,我需要像这样使用 word2vec 读取二进制文件:model = KeyedVectors.load_word2vec_format('site/wwwroot/GoogleNews-vectors-negative300.bin', binary=True, limit = 100000) 这种情况下的 url 是什么?我没有这样的文件或目录。
    猜你喜欢
    • 2019-12-30
    • 2021-08-25
    • 2021-06-08
    • 2018-07-13
    • 2021-09-01
    • 2016-11-25
    • 1970-01-01
    • 2016-05-24
    • 2022-12-21
    相关资源
    最近更新 更多