Announcement

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

  • downloading files using copy, invalid file specification error

    Dear all,
    I'm trying to write a loop downloading a series of zip files online. Based on what I read I thought that "copy" had this capability. However each of my efforts is met with the "invalid file specification" error. Here are a couple of examples of commands that generate the error.
    Code:
    copy "https://www.census.gov/popest/data/counties/asrh/2015/files/CC-EST2015-ALLDATA-06.csv"
    copy "http://usda.mannlib.cornell.edu/usda/nass/ChicEggs//2010s/2016/ChicEggs-10-21-2016.zip"
    I've tried using different current directories, thinking perhaps the pathway was too long, to no avail. What am I missing?

  • #2
    After playing with this some more, it worked once I specified the directory where I wanted to save the file in the same line:
    Code:
    copy "https://www.census.gov/popest/data/counties/asrh/2015/files/CC-EST2015-ALLDATA-06.csv" "C:\Users\Conner\Downloads"
    The above example works fine. This was a bit confusing as I had assumed that if I did not specify a pathway for storing the file, it would be saved to my current working directory.

    Comment


    • #3
      That's not the point in question. copy requires two arguments; there is no default second argument if you give just one. On directory, you are right: the directory defaults to the current directory, but a filename is needed regardless.

      See the help, always the first place to look. Whatever may be familiar from elsewhere doesn't affect the syntax of the Stata command.

      Comment

      Working...
      X