Import csv data as array in mongodb using mongoimport

后端 未结 2 492
[愿得一人]
[愿得一人] 2021-01-13 07:31

I have been trying to import the csv data into mongodb using mongoimport. The collection is like this:

{
id:\"122234343\",
name: \"name1\",
children: [\"2223         


        
2条回答
  •  Happy的楠姐
    2021-01-13 08:22

    collection is like below:

       {
           "_id" : ObjectId("580100f4da893943d393e909"),
           "username" : "crystal",
           "likes" : [ "running", "pandas", "software development" ]
        }
    

    below command for csv to mongodb:

    mongoimport --db users --type csv --headerline --file /opt/backups/contacts.csv
    

    actually Mongodb is non relational db so no need of creating two csv to import

提交回复
热议问题