How can I import JSON from a text file into MongoDB -
i have text file following json , text file size around 60 mb.
{ "houseno":"12345678", "location":"india" -- -- } { "houseno":"1245678", "location":"uk" -- -- }
i want import json data in same collection.i m not getting idea how import text file json data mongodb
any 1 have idea or suggestion how ..?
as experience, should try mongoimport. then, can import json follows
// --jsonarray output json array rather 1 object per line mongoimport -d dbname -c collectionnameyoulike --file your.json --jsonarray
besides, mongoimport seems have format requirements json.
it should (one json object in 1 line)
{"houseno":"12345678","location":"india"} {"houseno":"1245678","location":"uk"}
instead of
{ "houseno":"12345678", "location":"india" } { "houseno":"1245678", "location":"uk" }
if omit --jsonarray
option, terminal complain. sorry, after writing down, find similar post might help: mongodb json import.
anyway, hope helps. mongodb version 2.6.6.
Comments
Post a Comment