vendredi 27 février 2015

geonames-dump to sqlite python error 'dict_items' object does not support indexing

i'm getting this error when running the python code from below


'dict_items' object does not support indexing


http://ift.tt/1BmLs1q


what the code does is get files from geonames and put the results in a sqlite database.


it runs fine unntil creating the tables



def create_tables(cur):
'''
Create empty tables which will be populated later.
'''
for table_name in TABLE_MAPPINGS.values():
cur.execute('DROP TABLE IF EXISTS %s' % table_name)
table_fields = [ "%s %s" % table_field.listitems()[0] for table_field in TABLE_FIELDS ]
cur.execute('CREATE TABLE %s (%s)' % (table_name, ','.join(table_fields)))


error specifics:



line 111, in <listcomp>
table_fields = [ "%s %s" % table_field.items()[0] for table_field in TABLE_FIELDS ]
TypeError: 'dict_items' object does not support indexing"


any ideas? thx!


Aucun commentaire:

Enregistrer un commentaire