cancel
Showing results for 
Search instead for 
Did you mean: 
Community Platform 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 ?

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group