Open Refine (previously Google Refine) is a data cleaning software that uses your web browser as an interface. This means it will look like it runs on the internet but all your data remains on your machine and you do not need internet connection to work with it.

The main aim of Refine is to help you exploring and cleaning your data before you use it further. It is built for large datasets – so don’t worry as long as your spreadsheets can hold the information, refine can as well.

Creating a new Project

To work with your data in Refine you need to start a new project.

Walkthrough: Creating a Refine project

  1. Start Refine – this will open a browser window pointing to http://127.0.0.1:3333 if this doesn’t happen open the link with your browser directly
  2. Create a new project: On the left tab select the “Create Project” tab:Cleaning Data with Refine
  1. Click on “Choose Files” to choose your downloaded file and click on “next” – you can also use the URL to the CSV directly if your data is hosted on the web.
  2. You will get a preview on how refine will interpret your data – if you have selected a well formatted CSV or other file: this should be pretty automatic.
  3. Review the preview carefully to make sure the data looks right. Double check character encoding. Much, but not all data uses UTF-8 these days, but make sure you don’t see any funny characters in preview.
  4. In our Case all the Column have no column headings – since the first row of the file is actually empty.Cleaning Data with Refine
  1. If you check further down, you’ll notice that the column headings for the data are in rows 5 and 6.
  2. Let’s tell refine where to find column information: On the bottom you can find settings on how refine should look for column information.
  3. We’ll tell it to ignore the first 5 lines, take the next 2 lines as column labels and ignore one further row:

Cleaning Data with Refine

  1. Great – now the preview looks much nicer.
  2. Name your project in the box on the top right side and click on “Create Project”.
  3. The project will open in the project view, this is the basic interface you are going to work with: by default refine shows only 10 rows of data, you can change this on the bar above the data rows. Also you can use the navigation on the right to see the next or previous rows.

You now have successfully created your first refine project. Remember: although it runs in a web-browser, the Refine server is still on your machine – all the data is there (so no worries if you handle sensitive information)

Sorting and Facetting

Once we created our project, let’s go and explore the data and the Refine interface a bit. Using Refine might be intimidating at first, since it seems so different from spreadsheets, once you get used to it you will notice how easily you can do things with it.

One of the commonly used functions in spreadsheets is sorting and filtering data – to figure out minima, maxima or things about certain categories. Refine can do the same thing.

Walkthrough: Sorting rows

    1. Refines handles data similar to a spreadsheet: you have rows, columns and cells – a cell is a field defined by a row and a column.
    2. To sort your rows based on a specific column click on the small downward triangle next to the column.Cleaning Data with Refine
  1. Select “Sort…” to open the sorting dialog.
  2. You can select what to sort the values as and then what order to sort in. (We’ll sort in text, since for now we only have text columns).

    Cleaning Data with Refine

  1. Click “OK” and your rows will be sorted based on the column.
  2. To undo the sort, click on the column options again, select “sort” then “remove sort”

Cleaning Data with Refine

The other frequently used function in Spreadsheets is filtering – in Refine this is called facetting. Facetting in Refine is really powerful – you will see in most of the rest of the Recipe we’ll use facets.

Walkthrough: Facetting rows based on a column

  1. Select the column options for the column you want to facet with
  2. Select “Facet”Cleaning Data with Refine
  1. You can facet differently for text, numbers or dates – let’s facet as text – click on “Text facet”
  2. This will open a facet in the left barCleaning Data with Refine
  1. Now select one or more of the choices and you’ll see how your data rows are limited to just those selected.
  2. Of course you can add more than one facet and thus filter more than once.
  3. Let’s add another facet: Note that one of the columns contain dates: we can add a timeline facet to let us select a date range

    Cleaning Data with Refine

  1. This will open a new facet looking like:

    Cleaning Data with Refine

  1. You can select a time frame by moving the indicators left and right.

Reconciling Columns

Sometimes humans make mistakes when they enter data – they mistype city names or put in characters they can not see but the computer can. (For example, you can add a simple space at the end of a name and the computer will think they are different). For this let’s create a text facet for the cities:

Walkthrough: Reconciling Columns

  1. Create a text facet for the City column
  2. Scroll down where it says La Paz: see how many different ways there are to write la paz?Cleaning Data with Refine
  1. Let’s fix this! This is so common that refine has a built in mechanism for detecting these kind of differences.
  2. Click on the “Cluster” button on the top right in the facet.

    Cleaning Data with Refine

  1. Now check all the things Refine correctly noticed as similar
  2. Click on the “Merge Selected & Re-Cluster” button. Play with the keying function and methods on top to identify further possible merges.

Making city names look nice

Did you notice how most of the Cities are all uppercase? It’s rare to read them like this. And maybe you want to have nicer looking names: No problem. Refine supports this.

Walkthrough: Changing Case in Refine

  1. Let’s change the case in our city column from all uppercase to titlecase
  2. To do this, open the column options, go to edit cells -> common transforms -> to titlecase

    Cleaning Data with Refine

  1. Tada – magically your names have been converted.

Congratulations! You successfully cleaned up a dataset using Refine!

Michael lives in Vienna and works as a Data Wrangler with the Open Knowledge Foundation mostly around the School of Data. After a detour in biomedical research, where he learned to love datawrangling, he spent some time doing advocacy for his passion: freedom in the digital age. He joined the Open Knowledge Foundation to satisfy his curiosity. He will gladly jump on any topic that you point him to. – See more at: http://okfn.org/about/team/#Michael_Bauer_8212_Data_Wrangler_School_of_Data