kensho-technologies / qwikidata

Python tools for interacting with Wikidata

Home Page:http://qwikidata.rtfd.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

basic_json_dump.py yields: TypeError: 'list' object is not an iterator

Mark-L6n opened this issue · comments

When using the example code from https://github.com/kensho-technologies/qwikidata/tree/develop/examples/basic_json_dump.py (which appears to be the same as the docs), I get the following error messages:

File "test-qwikidata.py", line 56, in <module>
    dump_entities_to_json(politicians, out_fname)
File "path/to/py35/lib/python3.5/site-packages/qwikidata/utils.py", line 31, in dump_entities_to_json
    ent = next(entities, None)
TypeError: 'list' object is not an iterator

Used dump latest-all.json.bz2 downloaded 11/4/22 from here
Occurs in both python 3.5 and 3.10.

Is there a way around this?

hey @Mark-L6n , thanks for opening an issue ... looks like this PR introduced this issue ... I can take a look tonight

to check if my hunch is correct you could try passing iter(politicians) to the dump_entities_to_json function

Your hunch is correct, that works, thanks!

fixed in #36 and new version pushed to PyPI, thanks again for the report!
https://pypi.org/project/qwikidata/