Last active
February 10, 2019 23:23
-
-
Save maxday/dc0bfbdb460dbe969e8c7aa790923497 to your computer and use it in GitHub Desktop.
importing data 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
#first, let's unzip the fetched archive | |
gunzip out.json.gz | |
#second, import data into mongo thanks to mongoimport | |
ls -1 out.json | while read jsonfile; do mongoimport - host $MONGODB_HOST - db $MONGODB_DB -u $MONGODB_USER -p $MONGODB_PASS - collection $MONGODB_COLLECTION - file $jsonfile - batchSize 500; done | |
#finally, remove the uncompressed file | |
rm out.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment