0

I am trying to iterate through a list of files in a folder. As iterate through them I would like to add each and everyone of them. however, I receive TypeError: 'collection' object is not callable.

ive tried changing the directories and how I access mlab to no avail. I not sure if the file names having spaces in them is an issue. ive tried altering a couple of files but its still the same issue.

URI = 'mongodb://test:fake_pass@ds149984.mlab.com:49984/try2'

client = MongoClient(URI)
collection_sudo_freedom = client['sudo_freedom']



directory = os.listdir('C:/Users/Maximvs/Documents/Scraper_Plans')
print(len(directory))

for file in directory:
    # print(type)file)
    folder = 'C:/Users/Maximvs/Documents/Scraper_Plans/'
    Datafile = file
    fullDirectory = folder + Datafile
    # print(fullDirectory)

    with open(fullDirectory) as f:

        file_data = json.load(f)

        collection_sudo_freedom.insert_one(file_data)

    client.close()

I would like to upload all 312 files in my folder to mlabs(sudo_freedom collection).

0 Answers0