alex9smith / gdelt-doc-api

A Python client for the GDELT 2.0 Doc API
MIT License
100 stars 23 forks source link

Fix `multi_repeat` spacing #12

Closed alex9smith closed 2 years ago

alex9smith commented 2 years ago

By adding a space after AND in the query string. This missing space was stopping the API from parsing the query string. The error response was a plain text string with a 200 response code, so it was parsed into bytes, leading to pandas trying to parse a string of numbers into a dataframe which failed with errors like:

TypeError                                 Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_1576\752362330.py in <module>
      2
      3 # Search for articles matching the filters
----> 4 articles = gd.article_search(f)
      5
      6 # Get a timeline of the number of articles matching the filters

~\.conda\envs\newEnv\lib\site-packages\gdeltdoc\api_client.py in article_search(self, filters)
     77         """
     78         articles = self._query("artlist", filters.query_string)
---> 79         if "articles" in articles:
     80             return pd.DataFrame(articles["articles"])
     81         else:

TypeError: argument of type 'int' is not iterable

Closes #11

priolap commented 2 years ago

Hi @alex9smith,

the issue seems to persist when the query has the "OR" operator with the same output result:

TypeError: argument of type 'int' is not iterable

11

alex9smith commented 2 years ago

Hmm ok. Thanks for reporting @priolap . I'll take a look