cancel
Showing results for 
Search instead for 
Did you mean: 
Get Started Discussions
Start your journey with Databricks by joining discussions on getting started guides, tutorials, and introductory topics. Connect with beginners and experts alike to kickstart your Databricks experience.
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

 

0 REPLIES 0

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now