使用ABFSS路径在Azure Data Lake中获取最新的修改时间

发布于 2025-02-09 09:00:30 字数 729 浏览 2 评论 0原文

>>> os.stat("abfss://path")
FileNotFoundError: [Error 2] No such file or directory: 'abfss://path'

OS软件包仅适用于安装点,但是我不允许在项目中使用安装点,还有其他方法可以获取最新的修改后的文件夹时间,该文件夹中存在于Azure Data Lake Storage中

答案: 这就是我终于做到的。
通过使用datalakeserviceclient

storage_account_url="{}://{}.dfs.core.windows.net".format("https",account_name)
service_client = DataLakeServiceClient(account_url=storage_account_url, credential=account_key)
directory_client = service_client.get_directory_client(container_name, directory_name)
directory_properties = directory_client.get_directory_properties()
last_modified_date = properties['last_modified']
>>> os.stat("abfss://path")
FileNotFoundError: [Error 2] No such file or directory: 'abfss://path'

os package only works with mount points, but I'm not allowed to use mount points in my project, is there any other way to get the latest modified time of folder which is present in azure data lake storage

Answer:
This is how I finally did it.
by using DataLakeServiceClient class

storage_account_url="{}://{}.dfs.core.windows.net".format("https",account_name)
service_client = DataLakeServiceClient(account_url=storage_account_url, credential=account_key)
directory_client = service_client.get_directory_client(container_name, directory_name)
directory_properties = directory_client.get_directory_properties()
last_modified_date = properties['last_modified']

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文