Created
March 15, 2015 09:33
-
-
Save fabien0102/88dcaa184d801fd5e67a to your computer and use it in GitHub Desktop.
Import multiple json files into mongoDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ls -1 *.json | while read jsonfile; do mongoimport -d support -c logs -file $jsonfile --jsonArray -type json; done |
The way at the moment is:
ls -1 *.json | while read jsonfile; do mongoimport -h <HOST> -d <DB> -c <COLLECTION> -u <username> -p <password> --file $jsonfile --jsonArray --type json; done
Missing some dashes.
how to execute script in windows machine?? As in command prompt linux command will not work
@fabien0102
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
when i tried to i got some eror like
2017-07-27T10:56:41.762-0400 error parsing command line options: unknown option "type"
2017-07-27T10:56:41.762-0400 try 'mongoimport --help' for more information
2017-07-27T10:56:41.770-0400 error parsing command line options: unknown option "type"
2017-07-27T10:56:41.770-0400 try 'mongoimport --help' for more information
how i can upload bunch of .jsonfiles from particular folder suppose my folder location is /home/hades3/Desktop/converter/ ,data base name 'test' and collection is docs.
do i need to change the .json files name in accordance with collection name like docs1,docs2,docs3....