BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mitchell_keener
Obsidian | Level 7

Hello, 

 

I am trying to extract text files that are saved within multiple zip files. For example, I need to extract a text file within a structure such as "C:\Users\myname\Documents\files.zip\specifictextfile.zip\mydata.txt". 

 

In my case, each text file is saved within their own zip file inside "files.zip". I have been able to successfully extract the text file within a single zip level, so something like  "C:\Users\myname\Documents\specifictextfile.zip\mydata.txt" but I cannot get it out of the two level zips. 

 

This resource was extremely helpful with extracting from a one level zip: https://blogs.sas.com/content/sasdummy/2015/05/11/using-filename-zip-to-unzip-and-read-data-files-in...

 

Even if I could just extract the second level zips into their own folder, I could use the code at the link above to extract the text files from there. Does anyone know if this is possible or have any ideas how to do this? I could resort to manually extracting the "files.zip" first then using sas to read the txt files within each "specifictextfile.zip" zip, but I would rather not if possible. Let me know if I can provide additional information to assist with my question. The only example code I have was the code used in the blog to extract from a single zip file so I did not bother including it. Thanks so much. 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Nope.  Extract the embedded ZIP to a physical file, perhaps in your WORK directory.  Then you can extract the files from that ZIP file.  Repeat as many times as they have levels of nesting.

 

That is just a silly way to send data.

They should have just copied the files from the sub-files into the target ZIP as folders.  Storing a ZIP file in a ZIP file is just adding work for you without any added value.

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Nope.  Extract the embedded ZIP to a physical file, perhaps in your WORK directory.  Then you can extract the files from that ZIP file.  Repeat as many times as they have levels of nesting.

 

That is just a silly way to send data.

They should have just copied the files from the sub-files into the target ZIP as folders.  Storing a ZIP file in a ZIP file is just adding work for you without any added value.

mitchell_keener
Obsidian | Level 7
Thanks for the reply. Much appreciated!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2337 views
  • 0 likes
  • 2 in conversation