[英]get all the contents of data lake gen2 folder in a list azure synapse workspace
I am brand new to Azure. I have created a data lake gen2 storage account and a container inside it and saved some files and folders in it.I want to list all the files and folders in azure synapse notebook so that i can process a particular file.我是 Azure 的新手。我在其中创建了一个数据湖 gen2 存储帐户和一个容器,并在其中保存了一些文件和文件夹。我想列出 azure 突触笔记本中的所有文件和文件夹,以便我可以处理特定的文件。 I am using this command
我正在使用这个命令
mssparkutils.fs.ls("abfss://iogen2@demoadlsgen2.dfs.core.windows.net/first/")
but it giving me only one output like:但它只给我一个 output,比如:
[FileInfo(path=abfss://iogen2@demoadlsgen2.dfs.core.windows.net/first/stocks, name=stocks, size=0]
I want my answer in a list like:我希望我的答案在如下列表中:
'abfss://iogen2@demoadlsgen2.dfs.core.windows.net/first/stocks/',
'abfss://iogen2@demoadlsgen2.dfs.core.windows.net/first/stocks/2022-03-06/',
'abfss://iogen2@demoadlsgen2.dfs.core.windows.net/first/stocks/2022-03-06/csv_files/',
'abfss://iogen2@demoadlsgen2.dfs.core.windows.net/first/stocks/2022-03-06/csv_files/demo.csv'
Apparently when i am using os.listdir it is giving an error:显然,当我使用 os.listdir 时出现错误:
FileNotFoundError: [Errno 2] No such file or directory:
Can anyone please help me in this谁能帮我解决这个问题
As per the repro from my end, it shows all the files in the folder.根据我的复制,它显示了文件夹中的所有文件。
Here is files contained in the folder named sample:以下是名为 sample 的文件夹中包含的文件:
I'm able to get the all the files contained in the folder named sample:我能够获取名为 sample 的文件夹中包含的所有文件:
If you want to use the os.listdir
you need to use file mount/unmount API in Synapse .如果要使用
os.listdir
,则需要在 Synapse 中使用文件 mount/unmount API 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.