mra1385 / EIA-python

Python Wrapper for the Energy Information Administration (EIA) API
55 stars 13 forks source link

keyword search broken #1

Closed ringjohn closed 5 years ago

ringjohn commented 6 years ago

Hello, thanks for making this API.

The keyword search function seems to be broken when I tried it.

code snippet per the api documentation:

keyword_search = api.data_by_keyword(keyword=['crude oil', 'price'],
                                     filters_to_keep=['brent'],
                                     filters_to_remove=['AEO2015'],
                                     rows=1000)

returns this result:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-3dd583f69009> in <module>()
      2                                      filters_to_keep=['brent'],
      3                                      filters_to_remove=['AEO2015'],
----> 4                                      rows=1000)

C:\Anaconda3\lib\site-packages\eia\api.py in data_by_keyword(self, keyword, filters_to_keep, filters_to_remove, rows)
    299                                                  filters_to_keep,
    300                                                  filters_to_remove,
--> 301                                                  rows)
    302 
    303         url_data = 'http://api.EIA.gov/series/?series_id={}&api_key={}&out=json'

C:\Anaconda3\lib\site-packages\eia\api.py in search_by_keyword(self, keyword, filters_to_keep, filters_to_remove, rows, return_list)
    165                 (search.json().get('response').get('docs')):
    166             for k in search.json()['response']['docs']:
--> 167                 categories_dict[k['name']] = {}
    168                 categories_dict[k['name']]['Units'] = k['units']
    169                 categories_dict[k['name']]['Frequency'] = k['frequency']

TypeError: unhashable type: 'list'
cminal29 commented 5 years ago

I also faced issue while using EIA_python,

Traceback (most recent call last): File "", line 4, in File "eia/api.py", line 301, in data_by_keyword rows) File "eia/api.py", line 167, in search_by_keyword categories_dict[k['name']] = {} TypeError: unhashable type: 'list'

Is the error I am facing while using "api.data_by_keyword" function

mra1385 commented 5 years ago

Thank you for bringing this issue to my attention. It appears that EIA recently changed a structure of the json data that is returned when a search query is made. I've made a minor change to the code (now version 1.22). Please let me know if you continue to have problems.

cminal29 commented 5 years ago

Hello @mra1385 . I tried to use the function again. But unfortunately it is still giving me error. It is related to json.

mra1385 commented 5 years ago

@cminal29 Are you sure you're using the latest version 1.22? I just tested it again and it seems to be working fine. Perhaps try removing and re-installing the module. If you send me the exact line of code you're entering, which is giving you the error, I can test it out. Thanks.

cminal29 commented 5 years ago

@mra1385 ,

Hey, its working absolutely fine. ITs the version problem as you pointed out. I freshly installed 1.22. It working working fine..

Thanks :)

ringjohn commented 5 years ago

Thank you @mra1385!

On Mon, Jul 30, 2018 at 1:13 AM, Minal notifications@github.com wrote:

@mra1385 https://github.com/mra1385 ,

Hey, its working absolutely fine. ITs the version problem as you pointed out. I freshly installed 1.22. It working working fine..

Thanks :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mra1385/EIA-python/issues/1#issuecomment-408757626, or mute the thread https://github.com/notifications/unsubscribe-auth/AROH6tmzcaOpXwI8tsg9X_QIgYWIDEwaks5uLqP2gaJpZM4Tiqqf .