Skip to content

Instantly share code, notes, and snippets.

@ettorerizza
Last active April 28, 2018 00:04
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ettorerizza/053af2fef50ff98915c485a6b36c018e to your computer and use it in GitHub Desktop.
Save ettorerizza/053af2fef50ff98915c485a6b36c018e to your computer and use it in GitHub Desktop.
a mini Python3 script that transforms a list of operations performed in Open Refine into a text file easier to read. To use it, paste your Open Refine "undo/redo" history in a file named, for example, "operations.json", place this file in the same folder as the Python script, and run this command : python refinetranslator.py operations.json
#!/usr/bin/python3
import json
import sys
with open(sys.argv[1], "r") as infile:
data = json.load(infile)
outfile = open(sys.argv[1]+".txt", 'w')
count = 1
for el in data:
outfile.write(str(count) + '\t' + el['description'] + '\n')
count += 1
outfile.close()
#!/usr/bin/python3
#Batch version of refinestranslator.
#Put the script in a folder containing a bunch of Open Refine json files and simply type in command line :
#python refinetranslatorbatch.py
import json
import glob
for filename in glob.glob('*.json'):
with open(filename, "r") as infile:
data = json.load(infile)
outfile = open(filename + ".txt", 'w')
count = 1
for el in data:
outfile.write(str(count) + '\t' + el['description'] + '\n')
count += 1
outfile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment