Last active
April 28, 2018 00:04
-
-
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
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/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() |
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/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