我试图在Databricks笔记本中使用Python从Azure Data lake读取一个文件。 这是我使用的代码
from azure.storage.filedatalake import DataLakeFileClient
file = DataLakeFileClient.from_connection_string("DefaultEndpointsProtocol=https;AccountName=mydatalake;AccountKey=******;EndpointSuffix=core.windows.net",file_system_name="files", file_path="/2020/50002")
with open("./sample.txt", "wb") as my_file:
download = file.download_file()
content = download.readinto(my_file)
print(content)
我得到的输出是0。你能指出我做错了什么吗。我的期望是打印文件内容
from_connection_string方法返回一个
DataLakeFileClient
,您无法使用它下载文件如果你想下载一个文件到本地,你可以参考我下面的代码
如果您想要更多示例代码,可以参考以下文档:Azure Data Lake Storage Gen2
相关问题 更多 >
编程相关推荐