Last active
July 31, 2018 07:42
-
-
Save dsaiztc/a0860f5bf244ef048b4e61b1a0c9e2b6 to your computer and use it in GitHub Desktop.
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
cursor = None | |
rows = [] | |
total_rows = -1 | |
while(True): | |
try: | |
total_rows += 1 | |
row = next(cursor) | |
rows.append(row) | |
except bson.errors.InvalidBSON: | |
logger.exception('Failed to parse document') | |
except StopIteration: | |
break | |
logger.debug('Parsed {}/{} documents from Mongo DB collection (out of a total count of {})'.format( | |
cursor.retrieved, | |
total_rows, | |
cursor.count() | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment