|
GRELOtherFunctions
Other functions supported by the Google Refine Expression Language (GREL)
See also: All GREL functions. type(o)Returns the type of o, such as undefined, string, number, etc. hasField(o, string name)Returns a boolean indicating whether o has a field called name. For example, cell.hasField("value") always returns true, as every cell has a value field. jsonize(value)Quotes a value as a JSON literal value. parseJson(string s)Parses s as JSON. get can then be used with parseJson, e.g., parseJson(" { 'a' : 1 } ").get("a")returns 1. parseHtml(string s)returns a full html document and adds any missing closing tags. You can then extract or .select() which portions of the html document you need for further splitting, partitioning, etc. An example of extracting all table rows <tr> from a <div> using parseHtml().select() together is described more here select(Element e, String s)returns an element from an HTML doc element using selector syntax. This function can be used with most of the Jsoup selector syntax as documented here: http://jsoup.org/cookbook/extracting-data/selector-syntax htmlAttr(Element e, String s)returns a value from an attribute on an Html Element. htmlText(Element e)returns the text from within an element (including all child elements). innerHtml(Element e)returns the innerHtml of an HTML element. outerHtml(Element e)??? ownText(Element e)`Gets the text owned by this HTML element only; does not get the combined text of all children. cross(cell c, string projectName, string columnName)Returns an array of zero or more rows in the project projectName for which the cells in their column columnName have the same content as cell c. (Similar to a lookup) Consider 2 projects with the following data My Address Book
Christmas Gifts
Now in the project "Christmas Gifts", we want to add a column containing the addresses of the recipients, which are in project "My Address Book". So we can invoke the command "Add column based on this column" on the "recipient" column in "Christmas Gifts" and enter this expression cell.cross("My Address Book", "friend").cells["address"].value[0]When that command is applied, the result is Christmas Gifts
facetCount(choiceValue, string facetExpression, string columnName)Returns the facet count corresponding to the given choice value
If we wanted to show how many of each gift we had given, we could use the following expression: facetCount(value, "value", "gift") This would then complete the table as so:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
very good and very helpful
is it possible to use parsJson to pull in an array, something like parseJson(" { 'a' : 1 } ").getAll("a") ?