cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
Introduction
The purpose of this forum post is to automate the download of data from mongodb based on specific fields. At the end of this post, you should have an automated Windows Scheduller process running that downloads the data from a mongodb instance into a csv file.
Note that you also have the possibility to automate the download to csv as a pre-build plugin; this is not going to be covered in this post, but at the end you can find a reference about how to do so.
Step 0
Make sure you have a working server and a connection to mongodb running.
For the purpose of this example, import the "mongo_sample.json" file into the collection "mongo_sample" of mongodb using the following command.
Please edit it to accommodate your mongodb installation and json file path:
c:\mongodb\bin\mongoimport --collection mongo_sample --file c:\sample\mongo_sample.json --jsonArray
Step 1
Test the command to export your data using "mongoexport". In the example below, we want to export the data from the database called "test" and collection "mongo_sample". The fields that we want to export are "city", "loc", "pop", "state", and "_id".
Please edit the command to accommodate your mongodb installation and csv file path:
c:\mongodb\bin\mongoexport --db test --collection mongo_sample --csv --out c:/sample/zips.csv --fields _id,city,loc,pop,state

Step 2
We are going now to create an executable file to run the command in the previous step. In a notepad, please write the command above and save the file as "mongotocsv.bat"
Step 3
Create a scheduled task using the mongotocsv.bat process. Here you have more information about the Windows Scheduler.
Step 4
In the Elasticube Manager, make sure to point to the csv file generated on the previous steps.
You also have the opportunity to automate the mongo export every time that the build runs. In this forum post you have information about creating a pre-build plugin

Version history
Last update:
‎03-02-2023 08:36 AM
Updated by:
Contributors
Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Product Feedback Forum:

Need additional support?:

Submit a Support Request

Sisense Privacy Policy