Jun-26-2019, 06:53 AM
I want to load JSON data into MongoDB using pymongo library.
I found that JSON data can be directly load using mongoimport using the command prompt using the following command.
mongoimport --db myTestDB --collection myTestCollection_Table --jsonArray --file D:\path\myJson1.json
But I want to how to do this using python pymongo library(without specifying keys or values separately in the code. as it is done in the above method)
I managed to load the JSON file data into python.
I found that JSON data can be directly load using mongoimport using the command prompt using the following command.
mongoimport --db myTestDB --collection myTestCollection_Table --jsonArray --file D:\path\myJson1.json
But I want to how to do this using python pymongo library(without specifying keys or values separately in the code. as it is done in the above method)
I managed to load the JSON file data into python.
with open(r'D:\path\example_2.json', 'r') as f: data = json.load(f)Appreciate if you can give some inputs on how to load above data into mongodb using python.