earthlab/earthpy

get_data puts quotes around zip files, causing extract to fail

nkorinek opened this issue · 1 comments

Describe the bug
When calling et.data.get_data on some urls, there are quotes around the file names retrieved from the url that cause the filetype check to fail. This is due to the fact that the filetype check uses .endswith() to check the extension of the file. Since there are quotes around the file name, including the extension, the check fails and the data isn't extracted like we want it to be.

To Reproduce
Steps to reproduce the behavior:
run the following code

import earthpy as et
et.data.get_data(
    url="https://opendata.arcgis.com/datasets/955e7a0f52474b60a9866950daf10acb_0.zip")

Expected behavior
Since it's a zipfile, we would normally expect the data to be downloaded and extracted into a file. However, you'll notice that it just downloads the whole zipfile.

**What Operating System Are you Running? **

  • Linux

Possible Fix
The issue is really just the quotes. I fixed it locally by adding this line of code before the filetype check:

if fname.endswith('"') and fname.startswith('"'):
      fname = fname[1:-1]

Not sure if this fix is to specific for what we want to do, but it worked! Let me know, I could make a real quick PR for this if we want @lwasser

closing via #564