Skip to content

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

License

Notifications You must be signed in to change notification settings

RubyOnWorld/refine-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages