CoronaWhy / task-geo

"Help us understand how geography affects virality."
MIT License
10 stars 20 forks source link

Error 500 when calling us_census() #37

Open juancalvof opened 4 years ago

juancalvof commented 4 years ago

Error

data_us_census = ds.us_census.us_census() Traceback (most recent call last): File "C:\Users\juanc\Anaconda3\envs\coronawhy\lib\site-packages\IPython\core\interactiveshell.py", line 3331, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in data_us_census = ds.us_census.us_census() File "c:\users\juanc\desktop\01 juan calvo\01 big data\01 proyectos\covid-19\code\repositories\task-geo\task_geo\data_sources\demographics\us_census\us_census.py", line 31, in us_census df = us_census_connector() File "c:\users\juanc\desktop\01 juan calvo\01 big data\01 proyectos\covid-19\code\repositories\task-geo\task_geo\data_sources\demographics\us_census\us_census.py", line 47, in us_census_connector urllib.request.urlretrieve(url, "uscensus.zip") File "C:\Users\juanc\Anaconda3\envs\coronawhy\lib\urllib\request.py", line 247, in urlretrieve with contextlib.closing(urlopen(url, data)) as fp: File "C:\Users\juanc\Anaconda3\envs\coronawhy\lib\urllib\request.py", line 222, in urlopen return opener.open(url, data, timeout) File "C:\Users\juanc\Anaconda3\envs\coronawhy\lib\urllib\request.py", line 531, in open response = meth(req, response) File "C:\Users\juanc\Anaconda3\envs\coronawhy\lib\urllib\request.py", line 641, in http_response 'http', request, response, code, msg, hdrs) File "C:\Users\juanc\Anaconda3\envs\coronawhy\lib\urllib\request.py", line 569, in error return self._call_chain(args) File "C:\Users\juanc\Anaconda3\envs\coronawhy\lib\urllib\request.py", line 503, in _call_chain result = func(args) File "C:\Users\juanc\Anaconda3\envs\coronawhy\lib\urllib\request.py", line 649, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 500: Internal Server Error

ManuelAlvarezC commented 4 years ago

Hi @JuanCalvoFerrandiz, and thanks for reporting.

I have been able to replicate it and will start fixing it soon. I will keep you updated.

DanielRobertNicoud commented 4 years ago

The .zip file that the program wants to download is this one: https://data.census.gov/cedsci/table?q=demographic%20data%20by%20county&hidePreview=false&tid=ACSCP5Y2018.CP05&vintage=2018&g=0100000US.050000

cgomez9 commented 4 years ago

What is causing the problem is that the dataset URL was obtained getting the link address for the downloaded file in the web browser. This URL has the following form:

https://data.census.gov/api/access/table/download?download_id=TOKEN

The problem is that this TOKEN is changed in each download, making it useless when trying to download the file multiple times. We need to find a URL using the API directly.