-
Notifications
You must be signed in to change notification settings - Fork 0
/
01-working-with-openrefine.html
157 lines (155 loc) · 7.98 KB
/
01-working-with-openrefine.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!DOCTYPE html>
<html>
<head>
<title>Author Carpentry</title>
<link rel="stylesheet" href="css/site.css">
</head>
<body>
<header>
<a href="http://authorcarpentry.github.io"><img src="img/AClogo.jpg" alt="Author Carpentry logo"></a>
</header>
<nav>
<ul>
<li>
<a href=".">Lesson</a>
</li>
<li>
<a href="00-getting-started.html">Topic 1</a>
</li>
<li>
<a href="01-working-with-openrefine.html">Topic 2</a>
</li>
<li>
<a href="mailto:[email protected]">Contact Us</a>
</li>
</ul>
</nav>
<section>
<h1 id="working-with-open-refine">
Working with Open Refine
</h1>
<p>
20 minutes
</p>
<hr />
<h2 id="learning-objectives">
Learning Objectives
</h2>
<ul>
<li>
Create a new OpenRefine project from a CSV file.
</li>
<li>
Recall what facets are and how they are used to sort and summarize data.
</li>
<li>
Recall what clustering is and how it is applied to group and edit typos.
</li>
<li>
Manipulate data using previous steps with undo/redo.
</li>
<li>
Employ drop-downs to split values from one column into multiple columns.
</li>
<li>
Employ drop-downs to remove white spaces from cells.
</li>
</ul>
<hr />
<h2 id="creating-a-project">
Creating a Project
</h2>
<p>
Start 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).
</p>
<p>
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.
</p>
<p>
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.
</p>
<p>
If you haven’t already, download the data from:<br /> <a href="https://www.dropbox.com/s/kbb4k00eanm19lg/Portal_rodents_19772002_scinameUUIDs.csv?dl=0">https://www.dropbox.com/s/kbb4k00eanm19lg/Portal_rodents_19772002_scinameUUIDs.csv?dl=0</a>
</p>
<p>
<strong>Once Refine is open, you’ll be asked if you want to Create, Open, or Import a Project.</strong>
</p>
<pre><code> To create a project,
- click Create... and it will bring you to "Get data from this computer."
- 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 tab-delimited, 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._</code></pre>
<h2 id="faceting">
Faceting
</h2>
<p>
<em>Exploring data by applying multiple filters</em>
</p>
<p>
OpenRefine supports faceted browsing as a mechanism for
</p>
<ul>
<li>
seeing a big picture of your data, and
</li>
<li>
filtering down to just the subset of rows that you want to change in bulk.
</li>
</ul>
<p>
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.
</p>
<p>
<a href="https://github.com/OpenRefine/OpenRefine/wiki/Faceting">More on faceting</a>
</p>
<pre><code> - 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).</code></pre>
<h2 id="cluster">
Cluster
</h2>
<p>
One of the most magical bits of Refine, the moment you realize what you’ve been missing. Refine has several clustering algorithms built in. Experiment with them, and learn more about these algorithms and how they work.
</p>
<p>
<a href="https://github.com/OpenRefine/OpenRefine/wiki/Clustering-In-Depth">More on clustering</a>
</p>
<p>
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.
</p>
<pre><code> - 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.</code></pre>
<h2 id="split-leading---trailing-whitespace-undo---redo">
Split / Leading - Trailing Whitespace / Undo - Redo
</h2>
<p>
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.
</p>
<pre><code> - Go to the drop-down tab at the top of the column that you need to split into multiple columns
- For example, go to the scientificName column > from drop-down choose Edit Column > Split into several columns
- In the pop-up, for separator, remove the comma, put in a space
- Remove the check in the box that says "remove column after splitting"
- You'll get two extra columns called, in this case: scientificName 1, scientificName 2
- This will reveal an error in a few names that have spaces at the beginning (so-called leading white space).
- These can be easily removed with another Refine feature in the column drop-down choices. See drop-down: Edit cells > Common transforms > Remove leading and trailing whitespace
- To Undo create columns, look just above the scientificName cluster in the left side of the screen. Click where it says Undo / Redo. Click back one step (all steps, all changes are saved here). Just go back to the previous step and click. The extra columns will be gone.</code></pre>
<p>
Previous: <a href="00-getting-started.html">Getting Started with OpenRefine</a> Next: <a href="02-scripts.html">Scripts from OpenRefine</a>
</p>
</section>
<footer>
<span>© Author Carpentry</span>
<span><a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img
alt="Creative Commons License" style="vertical-align: middle;"
src="https://i.creativecommons.org/l/by/4.0/80x15.png" /></a></span>
<span>This work is licensed under a <a rel="license"
href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution
4.0 International License</a></span>
</footer>
</body>
</html>