Announcement

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

  • "unzipfile" gives File Not Found error

    I am getting an error when using the unzipfile command.

    As shown by the "dir" command below, the file "test.zip" exists. However, it gives me a File Not Found error when I try to use the unzipfile command. When I open text.zip in Windows explorer, I can unzip the file and open its contents, so it's not an issue with the file being corrupt. I am having this issue with multiple .zip files.

    Code:
    . dir "C:\Users\jaa\test.zip"
    4575.0k   9/03/19 13:20  test.zip       
    
    . unzipfile "C:\Users\jaa\test.zip", replace
    file C:\Users\jaa\test.zip not found
    r(601);

  • #2
    Your directory listing certainly makes it appear that the file exists, but sometimes there are hidden characters or extra spaces that can cause issues with Stata "seeing" a file.

    Perhaps you might try this to verify that the file exists to Stata:
    Code:
    if fileexists("C:\Users\jaa\test.zip") di "File exists"
    Also, consider that "replace" sometimes returns a "File not found" error if the file actually exists and does not need to be replaced.

    Red Owl
    Stata/IC 16 (Windows 10, 64-bit)

    Edited: Added extra comment on behavior of "replace."
    Last edited by Red Owl; 03 Sep 2019, 13:01.

    Comment


    • #3
      I ran a little experiment and believe you may have found a bug in -unzipfile-. I was able to get the command to work by using -cd- as follows:
      Code:
      local mydir `c(pwd)'
      cd C:\Users\jaa
      unzipfile test.zip, replace
      cd `mydir'
      Red Owl
      Stata/IC 16 (Windows 10, 64-bit)

      Comment


      • #4
        I reported this issue to StataCorp with a demo code.

        Here is the response from StataCorp:

        Yes, this is a bug and the developers will be putting out a fix for this behavior in an update. For now you can also use the -version- command to get the old behavior that takes a path:

        version 14: unzipfile "<filepath>/<zipfilename>.zip"

        Red Owl
        Stata/IC 16 (Windows 10, 64-bit)

        Comment


        • #5
          Thanks to Red Owl and Jeff Ack for reporting this problem.

          This is a bug that affects Stata 16, but not prior versions. We will get this fixed, and released in an upcoming update.

          The best work around is to follow the suggestion by Red Owl and use a relative path. Using the version 14 prefix will work in most cases, but that will fail for files larger than 2GB.

          Comment


          • #6
            James Hassell (StataCorp) I believe this issue is not fixed in Stata 17 as well. Could you confirm?

            Comment


            • #7
              Suresh Paul the problem described above has been fixed in Stata 16 and does not exist in Stata 17. If you have found a bug, please report it to [email protected].

              Comment


              • #8
                For the record
                Code:
                help whatsnew16
                tells us that this bug was corrected in Stata 16 as part of the 30sep2019 update.

                Comment

                Working...
                X