I have a collecton named "sample" and database named "at" present in Mongo DB .
db.sample.find().pretty()
{
"_id" : "35004",
"city" : "ACMAR",
"pop" : 6055,
"state" : "AL"
}
{
"_id" : "35005",
"city" : "ADAMSVILLE",
"pop" : 10616,
"state" : "AL"
}
{
"_id" : "35006",
"city" : "ADGER",
"pop" : 3205,
"state" : "AL"
}
I have tried using mongo export query , but i was unsuccessful , please let me know where i am doing mistake .
I have tried using below ways , but always produced an error .
mongoexport --host localhost --db at --collection "sample" --csv --out text.csv --fields city,state
mongoexport --csv -o /D:/test.csv -d at -c sample -f city,state,pop
I was getting the following error , please help
Sun Mar 10 00:25:44 SyntaxError: missing ; before statement (shell):1
Format Option: Choose JSON-mongo shell/ JSON-mongoexport. Target: Choose between clipboard/file & make sure the file path is defined. Others: Choose whether to export with commas between documents or export as a document array. Output Preview: Displays the final JSON document.
mongoexport
must be run from your OS command shell, not the mongo shell.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With