You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _episodes/11-using-arrays-transformations.md
+16-20Lines changed: 16 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -86,30 +86,26 @@ Taking the same example again, this would result in a string with the subjects i
86
86
{:.instructor}
87
87
88
88
>## Reverse author names
89
-
>You may already have done the boolean exercise and have a facet containing the names in personal name first order. In this case, select the 'true' facet and start with the step **"2.1. On the ```Authors``` column use..."** below.
89
+
>You may already have done the boolean exercise and have a facet containing the names in personal name first order. In this case, select the 'true' facet and start with the step **"9. On the ```Authors``` column use..."** below.
90
90
>
91
91
>In this exercise we are going to use both the Boolean and Array data types.
92
92
>If you look at the Authors column, you can see that most of the author names are written in personal name first order. However, a few have been reversed to put the family name first.
93
93
>
94
94
>We can do a crude test for reversed author names by looking for those that contain a comma:
95
95
>
96
-
>1.1. Make sure you have already split the author names into individual cells using ```Edit cells->Split multi-valued cells``` (you should have done this in the Clustering lesson)
97
-
>1.2. On the Authors column, use the dropdown menu and select ```Facet->Custom text facet...```
98
-
>1.3. The ```Custom text``` facet function allows you to write GREL functions to create a facet
99
-
>1.4. In the Expression box type ```value.contains(",")```
100
-
>1.5. Click ```OK```
101
-
>1.6. Since the ```contains``` function outputs a Boolean value, you should see a facet that contains 'false' and 'true'. These represent the outcome of the expression, i.e. true = values containing a comma; false = values not containing a comma
102
-
>1.7. In this facet select 'true' to narrow down to the author names that contain a comma
103
-
>
104
-
>Now we have narrowed down to the lines with a comma in a name, we can use the GREL ```split``` function. This is different to the ```Split multi-valued cells``` operation we have previously used as it allows us to manipulate the content of a cell, rather than create new cells.
105
-
>
106
-
>2.1. On the ```Authors``` column use the dropdown menu and select ```Edit cells->Transform ```
107
-
>2.2. In the Expression box type ```value.split(", ")``` (make sure to include a space after the comma inside the split expression to avoid extra spaces in your author name later).
108
-
>2.3. See how this creates an array with two members in each row in the Preview column
109
-
>
110
-
>To get the author name in personal name first order you can reverse the array and join it back together with a space to create the string you need:
111
-
>
112
-
>3.1. In the Expression box, add to the existing expression until it reads ```value.split(", ").reverse().join(" ")```
113
-
>3.2. In the Preview view you should be able see this has reversed the array, and joined it back into a string
114
-
>* Click ```OK```
96
+
>1. Make sure you have already split the author names into individual cells using ```Edit cells->Split multi-valued cells``` (you should have done this in the Clustering lesson)
97
+
>2. On the Authors column, use the dropdown menu and select ```Facet->Custom text facet...```
98
+
>3. The ```Custom text``` facet function allows you to write GREL functions to create a facet
99
+
>4. In the Expression box type ```value.contains(",")```
100
+
>5. Click ```OK```
101
+
>6. Since the ```contains``` function outputs a Boolean value, you should see a facet that contains 'false' and 'true'. These represent the outcome of the expression, i.e. true = values containing a comma; false = values not containing a comma
102
+
>7. In this facet select 'true' to narrow down to the author names that contain a comma
103
+
>8. Now we have narrowed down to the lines with a comma in a name, we can use the GREL ```split``` function. This is different to the ```Split multi-valued cells``` operation we have previously used as it allows us to manipulate the content of a cell, rather than create new cells.
104
+
>9. On the ```Authors``` column use the dropdown menu and select ```Edit cells->Transform ```
105
+
>10. In the Expression box type ```value.split(", ")``` (make sure to include a space after the comma inside the split expression to avoid extra spaces in your author name later).
106
+
>11. See how this creates an array with two members in each row in the Preview column
107
+
>12. To get the author name in personal name first order you can reverse the array and join it back together with a space to create the string you need:
108
+
>13. In the Expression box, add to the existing expression until it reads ```value.split(", ").reverse().join(" ")```
109
+
>14. In the Preview view you should be able see this has reversed the array, and joined it back into a string
0 commit comments