Last active
October 3, 2015 20:44
-
-
Save nermolov/b4e5a8ea9e8c7dd78fc5 to your computer and use it in GitHub Desktop.
Quick and Dirty Textbook Decode - http://connected.mcgraw-hill.com/media/repository/premium_content/EBOOK/50000053/12/75/data/json/bentley/0050.txt - http://pastebin.com/raw.php?i=hwYx1zLg
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/python | |
import sys, getopt | |
import json | |
from pprint import pprint | |
def main(argv): | |
inputfile = '' | |
try: | |
opts, args = getopt.getopt(argv,"hi:",["ifile="]) | |
except getopt.GetoptError: | |
print 'test.py -i <inputfile>' | |
sys.exit(2) | |
for opt, arg in opts: | |
if opt == '-h': | |
print 'test.py -i <inputfile>' | |
sys.exit() | |
elif opt in ("-i", "--ifile"): | |
inputfile = arg | |
print 'Input file is ', inputfile | |
test = inputfile | |
print test | |
with open('{0}'.format(inputfile)) as data_file: | |
data = json.load(data_file) | |
pprint(data) | |
if __name__ == "__main__": | |
main(sys.argv[1:]) |
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
#!/bin/bash | |
python test.py -i $1 | grep text | sed -e s/u\'text\'\:// -e s/' 'u\'// -e s/\'},//g -e s/\'}]}//g -e "s/^[[:space:]]*$/\\n/g;s/[[:space:]]*$//" | sed ':a;N;$!ba;s/\n\n/ /g' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment