cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Community Discussions
Connect with fellow community members to discuss general topics related to the Databricks platform, industry trends, and best practices. Share experiences, ask questions, and foster collaboration within the community.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Unzip multiple zip files in databricks

traillog
New Contributor

I have a zip file which in turn has multiple zip files inside it. I tried to write a code in databricks notebook to unzip all these files at once, but I ran into an error. So I started to unzip these one by one, but the code which worked in unzipping the first file(parent zip file) does not work for the child zip files.  Should I have to follow a different approach?

# copy to dbfs
%fs cp 'abfss://testdata@flowwesteuropedevappsa.dfs.core.windows.net/lz/INDIA_archive_LTA1_0_20240530-142643067.zip' dbfs:/FileStore/shared_uploads

#rename files
old_name = r"dbfs:/FileStore/shared_uploads/INDIA_archive_LTA1_0_20240530-142643067.zip"
new_name = r"dbfs:/FileStore/shared_uploads/sample.zip"
dbutils.fs.mv(old_name, new_name)

#unzip parent file
%sh
unzip /dbfs/FileStore/shared_uploads/sample.zip

#here I get multiple zip files with the message inflating: zip1.zip, inflating: zip2.zip....

#unziping one child zip
%sh
unzip /dbfs/FileStore/shared_uploads/zip1.zip

 

1 REPLY 1

Kaniz_Fatma
Community Manager
Community Manager

Hi @traillog, Did you try this ?

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!