Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 7-Zip files

    I'm attempting to download and use a dataset saved as a "7-Zip" file, which unzipfile cannot open. I've searched within Stata, but I've come up with nothing mentioning the file type.

    I've successfully used this ado file that adds the gunzipfile command, but I wanted to check if there was an official alternative.

    If there's nothing else, then here's a solution for others attempting to unzip 7-Zip files within Stata.

  • #2
    Here is the author's website where these packages are mentioned: http://scholar.harvard.edu/chodorow-reich/data-programs

    Comment


    • #3
      Here are some examples of how I call the 7zip command line program in case anyone finds them useful. Like the author of gunzipfile, I also use the 7-Zip command line program 7za.exe for Windows to process archive files. I have 7za.exe located on my desktop in a folder called "7zip".

      An example of how I use 7zip from within Stata to extract the contents of a .7z file to a different directory than where the archive is located:
      Code:
      ** Unzip contents of testfile.7z to different directory
      ! C:\Users\User\Desktop\7zip\7za e -y C:\Users\User\Desktop\testfile.7z -oE:\temp\test\ -r
      There are numerous options available to customize your extraction. One of my favorite features is the ability to filter which files to extract:
      Code:
      ** Extract files with extension .xlsx
      ! C:\Users\User\Desktop\7zip\7za e -y C:\Users\User\Desktop\testfile.7z -oE:\temp\test\ *.xlsx -r
      
      ** Extract files with "blue" somewhere in the file name
      ! C:\Users\User\Desktop\7zip\7za e -y C:\Users\User\Desktop\testfile.7z -oE:\temp\test\ *blue* -r
      I am by no means an expert on 7zip. A lot of my learning was from trial and error. A convenient reference I've used for various 7zip extraction options can be found here.

      Comment

      Working...
      X