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.
Appreciate if you can give some inputs on how to load above data into mongodb using 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.
1 2 |
with open (r 'D:\path\example_2.json' , 'r' ) as f: data = json.load(f) |
Attached Files