When using Openshift, you must use environment variables to ensure that your values ββare always correct. Click here to learn more about Openshift Envrionment variables.
SSH to your openshift server, then run (do not forget to change the bold bits in the command according to your values) :
mongoimport --headerline --type csv \ --host $OPENSHIFT_NOSQL_DB_HOST \ --port $OPENSHIFT_NOSQL_DB_PORT \ --db **your db name** \ --collection **your collection name** \ --username $OPENSHIFT_NOSQL_DB_USERNAME \ --password $OPENSHIFT_NOSQL_DB_PASSWORD \ --file ~data
Note When importing csv files using mongoimport, data is saved as strings and numbers only . It will not save arrays or objects. If you have arrays or an object to save, you must first convert your csv file to the correct json file, and then the mongoimport json file.
source share