Skip to content

Instantly share code, notes, and snippets.

@pkulev
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkulev/51565464ca6533ede1e1 to your computer and use it in GitHub Desktop.
Save pkulev/51565464ca6533ede1e1 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
import os
import sys
usage = "USAGE: {0} path".format(sys.argv[0])
if len(sys.argv) != 2:
print usage
sys.exit(1)
else:
path = sys.argv[1]
if not os.path.isdir(path):
print "No such directory {0}".format(path)
sys.exit(1)
def bsondump(a, cur, files):
for file in [file for file in files if file.endswith(".bson")]:
name, ext = os.path.splitext(file)
os.system("bsondump {0} > {1}".format(file, name + ".json"))
def bsondumpdir(path, callback, arg):
os.path.walk(path, callback, arg)
if __name__ == "__main__":
bsondumpdir(path, bsondump, None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment