I have a list of dictionaries data_dump which contains dictionaries like:
d = {"ids": s_id, "subject": subject}
I'm following the tutorial trying to do a bulk insert:
connection = Connection(host,port)
db = connection['clusters']
posts = db.posts
posts.insert(data_dump)
Which fails with the following error:
File "/usr/local/lib/python2.7/dist-packages/pymongo/collection.py", line 312, in insert
continue_on_error, self.__uuid_subtype), safe)
bson.errors.InvalidStringData: strings in documents must be valid UTF-8
Please advise. Thanks
codecs.openfunction to read the file. Soopen("file.txt", "r")would becomeimport codecs; codecs.open("file.txt", "r", "utf-8")