Created
July 13, 2012 11:22
-
-
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
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
#!/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