0

I've been reading through the documentation for the Python client of OpenRefine (https://github.com/OpenRefine/refine-client-py) but it seems as though the link for "David Huynh's Refine tutorial" is broken.

Through my python code, I would like to import a csv file thats stored locally on my machine and automatically open the webpage (http://127.0.0.1:3333/) so that I can do the normal filtering of the data on the browser.

Please help.

1 Answers1

0

If you simply want to create an Open Refine project from Python, you could use this client.

Then, creating a OR new project will look something like that :

#!/usr/bin/python

import sys
sys.path.append("refine.py")
import refine

r = refine.Refine()
p = r.new_project("my.csv")
#print p.export_rows()

(make sure that Open Refine is launched)

By the way, here is the David Huyn's tutorial.

Ettore Rizza
  • 2,800
  • 2
  • 11
  • 23
  • Would I have to download refine.py first before I add it to the sys path? – AyeMarciMar Feb 14 '17 at 20:29
  • Yes, refine.py is the main script on the Github [link](https://github.com/OpenRefine/refine-python) above. You can store it wherever you want and call it with sys.path.append("/myfolder/refine.py") – Ettore Rizza Feb 14 '17 at 21:24
  • So the code works with no errors but how do I get the created project to appear in the dashboard of Open Refine in the browser? The created project isn't showing up anywhere – AyeMarciMar Feb 14 '17 at 23:34
  • You probably need to refresh the page. Now, you can also find a way to automatically launch OR from Python. [This](http://stackoverflow.com/questions/1811691/running-an-outside-program-executable-in-python) question could be usefull. – Ettore Rizza Feb 15 '17 at 08:02
  • I made a silly mistake in my code. It works flawlessly. Thank you so much. I appreciate the quick replies. – AyeMarciMar Feb 15 '17 at 18:25
  • You're welcome. This is the first little Python client for OR, written by David Huyn. The one you posted is more advanced, but like you, I've never been very successful in using it. – Ettore Rizza Feb 15 '17 at 18:32