facetsStart the program. (Double-click on the google-refine.exe file. Java services will start on your machine, and Refine will open in your Firefox browser).
Note the file types Open Refine handles: TSV, CSF, *SV, Excel (.xls .xlsx), JSON, XML, RDF as XML, Google Data documents. Support for other formats can be added with Google Refine extensions.
In this first step, we'll browse our computer to the sample data file for this lesson. In this case, I've modified the Portal_rodents csv file. I added several columns: scientificName, locality, county, state, country and I generated several more columns in the lesson itself (JSON, decimalLatitude, decimalLongitude). Data in locality, county, country, JSON, decimalLatitude and decimalLongitude are contrived and are in no way related to the original dataset. When doing this demo, the columns: JSON, decimalLatitude, decimalLongitude can be deleted, and then recreated if time, with a call to a locality service, and subsequent parsing of the JSON data returned by the service.
If you haven't already, download the data from:
https://www.dropbox.com/s/kbb4k00eanm19lg/Portal_rodents_19772002_scinameUUIDs.csv?dl=0
Once Refine is open, you'll be asked if you want to Create, Open, or Import a Project.
- Click Browse, find Portal_rodents_19772002_scinameUUIDs.csv
- Click next to open Portal_rodents_19772002_scinameUUIDs.csv
- Refine gives you a preview - a chance to show you it understood the file. If, for example, your file was really delimited with tabs, the preview might look strange, you would choose the correct separator in the box shown and click "update preview."
If all looks well, click "Create Project"
Exploring data by applying multiple filters
OpenRefine supports faceted browsing as a mechanism for
Typically, you create a facet on a particular column. The facet summarizes the cells in that column to give you a big picture on that column, and allows you to filter to some subset of rows for which their cells in that column satisfy some constraint. That's a bit abstract, so let's jump into some examples.
- Scroll over to the scientificName column
- Click the down arrow and choose > Facet > Text facet
- In the left margin, you'll see a box containing every unique, distinct value in the scientificName column and Refine shows you how many times that value occurs in the column (a count), and allows you to sort (order) your facets by name or count.
- Edit. Note that at any time, in any cell of the Facet box, or data cell in the Refine window, you have access to "edit" and can fix an error immediately. Refine will even ask you if you'd like to make that same correction to every value it finds like that one (or not).
At the bottom of the facet list, there is the option to Facet by choice counts. Clicking this opens a new dialog that can futher reduce your original facet (e.g., if you only wanted to look at a range, say, in the middle of the distribution without scrolling)
At the right of each text entry in the facet, there is an edit option. This can be very useful if you have fields with white space in them that make them appear to be unique, when in fact they are not. Explore this with the Ammospermophilus harrisi species.
You can decide what data you want to work on in a similar way to edit.
Because Refine does not operate on your original data, you can undo and redo as much as you need to without affecting anything. To see this in action, rename an element in the facet to something else. You can now go to the Undo/Redo section. If you select a previous edit, and go back to your facet, you can see that your renaming operation has been undone. This may not work exactly as you expect, so it's worth exploring to see how this operates.
When you're finished with your facet, you can remove it using the Remove All button
Question: Is it possible to skip around in your history, or can you make non-linear edits based on the history?
- Select the scientificName column again and go to "Facet | Customized facets | Duplicates facet"
- Selecting true/false will show you which entries in the scientificName column have duplicates (which may be OK, depending on your data)
You can see that by building up multiple facets you can really start to drill down into your data with little effort. This can even be further extended using Text filters. Check those out next.
One of the most magical bits of Refine is the ability to use some machine learning to look for patterns in your data values that might be hard to spot (like whitespace). This is called Clustering. Refine has several clustering algorithms built-in. Take some time to experiment with them, and learn more about these algorithms and how they work.
In OpenRefine, clustering refers to the operation of "finding groups of different values that might be alternative representations of the same thing". For example, the two strings "New York" and "new york" are very likely to refer to the same concept and just have capitalization differences. Likewise, "Gödel" and "Godel" probably refer to the same person.
- In this example, in the scientificName Text Facet we created in the step above, click the "Cluster" button.
- In the resulting pop-up window, you can change the algorithm method, and keying function. Try different combinations to see the difference.
- For example, with this dataset, the "nearest neighbor" method with the "PPM" keying function shows the power of clustering the best.
- Intentional errors in these scientific names have been introduced to show how errors (typos) in any position can be found with this method. All errors can then be fixed by simply entering the correct value in the box on the right. Often, the algorithm has guessed correctly.
- After corrections are made in this window, you can either Merge
and Close the Cluster pop-up, or Merge and Re-cluster.
If data in a column needs to be split into multiple columns, and the strings in the cells are separated by a common separator (say a comma, or a space), you can use that separator to divide up the bits into their own columns.
Previous: Getting Started with OpenRefine Next: Scripts from OpenRefine