Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Ruby client library for controlling Google Refine

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.textile
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
Octocat-spinner-32 google-refine.gemspec
README.textile

google-refine

is a Ruby Gem client library for Google Refine

If you want to port this to another language, check out the Refine API documentation.

Install

gem install google-refine

Example

Given that you have the following raw data:

  
    Date
    7 December 2001
    July 1 2002
    10/20/10
  

Google Refine lets you clean up the data and export your operation history as a JSON instruction set. Here is an example that extracts the year from the above dates:


  [
    {
      "op": "core/text-transform",
      "description": "Text transform on cells in column Date using expression grel:value.toDate()",
      "engineConfig": {
        "facets": [],
        "mode": "row-based"
      },
      "columnName": "Date",
      "expression": "grel:value.toDate()",
      "onError": "set-to-blank",
      "repeat": false,
      "repeatCount": 10
    },
    {
      "op": "core/text-transform",
      "description": "Text transform on cells in column Date using expression grel:value.datePart(\"year\")+1",
      "engineConfig": {
        "facets": [],
        "mode": "row-based"
      },
      "columnName": "Date",
      "expression": "grel:value.datePart(\"year\")",
      "onError": "set-to-blank",
      "repeat": false,
      "repeatCount": 10
    }
  ]

You can use this gem to apply the operation set to the raw data from ruby. You will need to have Google Refine running on your local computer, or specify an external address (see source):

  
    prj = Refine.new('date cleanup', 'dates.txt')
    prj.apply_operations('operations.json')
    puts prj.export_rows('csv')
    prj.delete_project
  

Which outputs:

  
    Date
    2001
    2002
    2010
  

Copyright

Copyright © 2011 David Huynh and Max Ogden. See LICENSE for details.

Something went wrong with that request. Please try again.