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
#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()
#!/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()