MongoDB CSV Export: One Array/Column & Array Index on rows, or vice versa
MongoDB CSV Export: One Array/Column &amp; Array Index on rows, or vice
  versa


I will suggest to you, if you are unable to import or export collections data from MongoDB CLI. Then you install the Compass, From MongoDB Compass you can easily import and export the collection data.
As per MongoDB documentation here MongoDB Compass works with MongoDB Server version 3.0 and higher, both Enterprise and Community editions. It runs on 64-bit versions of Mac OS X, Windows, Ubuntu 14.04+ and RHEL 7+.


  Note: As of MongoDB Server version 3.6, MongoDB packages a platform-specific Compass installation script with MongoDB
  Server downloads.


For example 

I have a database test and collection articles having the records such as 

&gt; use test
switched to db test
&gt; show collections
alpha
articles
books
oplog
people
sales
sample
team
users

&gt; db.articles.find().pretty();
{ "_id" : 1, "subject" : "coffee", "author" : "xyz", "views" : 50 }
{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 }
{ "_id" : 3, "subject" : "Baking a cake", "author" : "abc", "views" : 90 }
{ "_id" : 4, "subject" : "baking", "author" : "xyz", "views" : 100 }
{
        "_id" : 5,
        "subject" : "Café Con Leche",
        "author" : "abc",
        "views" : 200
}
{ "_id" : 6, "subject" : "Сырники", "author" : "jkl", "views" : 80 }
{
        "_id" : 7,
        "subject" : "coffee and cream",
        "author" : "efg",
        "views" : 10
}
{ "_id" : 8, "subject" : "Cafe con Leche", "author" : "xyz", "views" : 10 }
&gt;


The collections records are appearing in MongoDB Compass in Table format such as



Now I am going to export the collections records through MongoDB compass tool. After collecting with your host computer (either local or remote) with MongoDB compass tool . Select the database (here I have taken test database) then click on the collections name (here I have been taken articles) then click on the Collection menu tab. It will appears like that 



According to your desire you click on the option, As here I want to export the collection data in .csv format then I will click on export command and then the screen will be appears like that



Then browse the file location as per your desire and export the collection records in .csv format.

After exporting the collections records from the compass in .csv format the appearance in .csv of data will be look like as follows: