admin管理员组文章数量:1122832
Below is the code.
from zipfile import ZipFile
file_name = "XYZ.zip"
with ZipFile(file_name, 'r') as zip:
zip.printdir()
print('Extracting all the files now...')
zip.extractall(pwd=b'123123$SADMK6%002#')
print('Done!')
It is giving "FileNotFoundError
" error. Also, I can read other csv files inside ADLS using abfss path without providing accesskey of storage account.
Below is the code.
from zipfile import ZipFile
file_name = "XYZ.zip"
with ZipFile(file_name, 'r') as zip:
zip.printdir()
print('Extracting all the files now...')
zip.extractall(pwd=b'123123$SADMK6%002#')
print('Done!')
It is giving "FileNotFoundError
" error. Also, I can read other csv files inside ADLS using abfss path without providing accesskey of storage account.
1 Answer
Reset to default 0csv files are read using abfss path because you are using pandas
to read them and pandas uses fsspec
and adlfs
library which connects to azure storage account using credentials you given.
You did not provided any access key it still worked because it used you default credentials, and with the same you can read zip file like below.
from fsspec.implementations.zip import ZipFileSystem
strg_opt={'account_name': "jadls", 'anon': False}
tmp = ZipFileSystem(fo="abfs://data/zips/apache-maven-3.9.9-bin.zip",target_options=strg_opt)
tmp.zip.extractall(path="./maven")
Here, the path format should be
'abfs://{CONTAINER}/{FOLDER}/file_name'
refer this for more information.
Output:
In storage account
and extracted in local
If you are using Databricks environment, then mount your storage account using dbutils.fs.mount()
and use your initial code on that mount path.
本文标签: azureHow do I unzip a password protected zip file using Python inside ADLSStack Overflow
版权声明:本文标题:azure - How do I unzip a password protected zip file using Python inside ADLS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736312308a1935054.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
open
or pandas read csv? – JayashankarGS Commented Nov 21, 2024 at 8:54pwd
field while doingextractall
– JayashankarGS Commented Nov 22, 2024 at 4:46