Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Vienna from September 15-18, 2025, for the ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM. Get registered

Reply
MK007
Frequent Visitor

Issue accessing zip file from lakehouse using spark job definition

Hi all,

I have a spark job definition which contains a main definition file to programmatically extract a zip file from a lakehouse and extract the contents to a configured destination folder on the same lakehouse. I am using below code for file extraction:

 

 

 

def extract_zip_files(zipfilepath,outputpath):
with zipfile.ZipFile(zipfilepath,'r') as zfile:
zfile.extractall(path=outputpath)

 

 

 

The zip file path (ABFS path), zip file name and destination path (ABFS path) are passed from the command line arguments.

I am encountering below runtime issue while running the spark job:
FileNotFoundError: [Errno 2] No such file or directory: 'abfss://<My workspace ID>@onelake.dfs.fabric.microsoft.com/<My Lakehouse ID>/Files/MyFile.zip'

 

Please let me know if you have any suggestions or if need more information regarding this issue.

3 REPLIES 3
MK007
Frequent Visitor

Thank you @Anonymous for taking a look at this issue. I am trying to extract zip files using spark job defintion instead of a notebook. Within my spark job code, I have tried passing the file paths (ABFS, relative path, file api path) via command line arguments but encountered same error i.e. FileNotFoundError: [Errno 2] No such file or directory. 

Is there an approach to extract zip files within a spark job definition?

Anonymous
Not applicable

Hi @MK007,

I also not find the fact path of files, perhaps you can try to upload the files to environment and use correspond path to extract data: (you can try to use f"{notebookutils.nbResPath} + 'file the relative path'to read data from resource folder)

zipfilepath=f"{notebookutils.nbResPath}/env/Test/test.zip"

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

Hi @MK007,

I test with your code in notebook and find the 'zipfilepath' and 'outputpath' parameters should be the api path of files: (you can get it by right-click on the zip file and choose 'copy file api path' option)

import zipfile
zipfilepath="/lakehouse/default/Files/test.zip"
outputpath="/lakehouse/default/Files/Test/"
zfile= zipfile.ZipFile(zipfilepath,'r')
zfile.extractall(path=outputpath)

Result:
1.png

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June FBC25 Carousel

Fabric Monthly Update - June 2025

Check out the June 2025 Fabric update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.