Skip to content

Instantly share code, notes, and snippets.

@pgjones
Created July 13, 2012 11:22
Show Gist options
  • Save pgjones/3104389 to your computer and use it in GitHub Desktop.
Save pgjones/3104389 to your computer and use it in GitHub Desktop.
Load a ratdb file into a python dict using yaml and json_minify
#!/usr/bin/env python
# Author P G Jones - 13/07/2012 <p.g.jones@qmul.ac.uk>
# This script parses a ratdb file and loads the information into a python dict
import yaml # Needs installing, not part of the standard python library
import sys
from minify_json import json_minify # Available from https://github.com/getify/JSON.minify
def LoadRatDB( fileName ):
""" Load a ratdb file and return a dictionary of the contents."""
ratDBFile = open( fileName, "r" )
dataDict = yaml.load( json_minify( ratDBFile.read(), False ) )
ratDBFile.close()
return dataDict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment