【发布时间】:2020-08-25 07:24:53
【问题描述】:
我在 Azure 机器学习平台/云上运行 Python 代码,但我不知道如何将生成的数据帧保存到 Azure Blob 存储中的 csv 文件中。谁能告诉我该怎么做或指出我可以在哪里阅读更多相关信息?
【问题讨论】:
标签: python azure save azure-blob-storage blobstorage
我在 Azure 机器学习平台/云上运行 Python 代码,但我不知道如何将生成的数据帧保存到 Azure Blob 存储中的 csv 文件中。谁能告诉我该怎么做或指出我可以在哪里阅读更多相关信息?
【问题讨论】:
标签: python azure save azure-blob-storage blobstorage
您可以尝试使用以下 python 代码将文件上传到 Azure 博客吗:
global service_client
service_client = DataLakeServiceClient(account_url="{}://{}.dfs.core.windows.net".format("https", 'Storage_account_name'), credential='Storage_Account_Key')
#upload file to ADLS Gen 2
file_system_client = service_client.get_file_system_client(file_system="your_container_name")
directory_client = file_system_client.get_directory_client("my-directory")
file_client = directory_client.create_file("uploaded-file.txt")
local_file = open("C:\\Users\\xxxxxxx\\Desktop\\testFile.txt", 'r')
file_contents = local_file.read()
file_client.append_data(data=file_contents, offset=0, length=len(file_contents))
file_client.flush_data(len(file_contents))
有关完整代码的更多详细信息,请访问this link
【讨论】: