0.03
No commit activity in last 3 years
No release in over 3 years
Client library for interacting with Google Refine instances. Easily work with CSVs from the command line
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 2.1.6.1
>= 1.4.6
 Project Readme

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.