Skip to content

AndreyPlotnikov/mongocsvexport

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

mongocsvexport

Utility that produces a CSV of data stored in a MongoDB

The key feature is sub-ducuments and lists expansion.

Let's imagine we have collection which contains the following documents:

{
  "company": "Orange",
  "departments" : [
    { "title": "IT",
      "employees": [
        {"first_name" : "Andrey",
         "last_name"  : "Plotnikov"},
        {"first_name" : "Mithun",
         "last_name"  : "Chakraborty"} 
      ]},
    { "title": "Executive",
      "employees" : [
        {"first_name": "Robert",
         "last_name" : "Hunold"}
      ]
    }
  ]
}

{
  "company": "Banana",
  "departments" : [
    { "title": "Executive",
      "employees" : [
        {"first_name": "Joe",
         "last_name" : "Black"}
      ]
    }
  ]
}

And if we run mongocsvexport command in such way:

$ mongocsvexport -d testdt -c testcoll -f company,departments.title,departments.employees.last_name

We will get the following output:

Orange,IT,Plotnikov
Orange,IT,Chakraborty
Orange,Executive,Hunold
Banana,Executive,Black

About

Utility that produces a CSV of data stored in a MongoDB

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages