retrieve.py
import pymongo
from pymongo import MongoClient
import gridfs
connection = MongoClient('localhost', 27017)
db = connection['file_uploaded_new']
data = db['words.chunks']
retrieve = data.find()
for item in retrieve:
a=(str(item["data"]))
f=open(a,"rb")
line = f.readline()
print(line)
f.close()
Using this code gives me error:: Invalid argument: 'b\'PK\x03....'
I want to read the binary data in text format. How to approach it as above code only gives me binary data.I want to read binary file stored in data mongoDB in binary format using python script. P.S.: I uploaded into mongoDB using gridfs in node js.