Skip to content

Instantly share code, notes, and snippets.

@maxday
Last active February 10, 2019 23:23
Show Gist options
  • Save maxday/dc0bfbdb460dbe969e8c7aa790923497 to your computer and use it in GitHub Desktop.
Save maxday/dc0bfbdb460dbe969e8c7aa790923497 to your computer and use it in GitHub Desktop.
importing data into MongoDB
#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