All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.refine.grel.FunctionDescription.properties Maven / Gradle / Ivy

Go to download

OpenRefine is a free, open source power tool for working with messy data and improving it

There is a newer version: 3.8.2
Show newest version
# Functions
# 1. Arrays
arr_args_to_array=Returns all arguments passed to it as an array
arr_in_array=Returns true if the array contains the desired string, and false otherwise. Will not convert data types.
arr_join=Joins the items in the array with sep, and returns it all as a string.
arr_reverse=Reverses array a.
arr_sort=Sorts the array in ascending order. Sorting is case-sensitive, uppercase first and lowercase second.
arr_uniques=Returns the array with duplicates removed. Case-sensitive.

# 2. Booleans
bool_and=Uses the logical operator AND on two or more booleans to output a boolean. Evaluates multiple statements into booleans, then returns true if all the statements are true. For example, (1 < 3).and(1 < 0) returns false because one condition is true and one is false.
bool_or=Uses the logical operator OR on two or more booleans to output a boolean. For example, (1 < 3).or(1 > 7) returns true because at least one of the conditions (the first one) is true.
bool_not=Uses the logical operator NOT on a boolean to output a boolean. For example, not(1 > 7) returns true because 1 > 7 itself is false.
bool_xor=Uses the logical operator XOR (exclusive-or) on two or more booleans to output a boolean. Evaluates multiple statements, then returns true if only one of them is true. For example, (1 < 3).xor(1 < 7) returns false because more than one of the conditions is true.

# 3. Date
date_part=Returns part of a date. The data type returned depends on the unit. See https://openrefine.org/docs/manual/grelfunctions/#datepartd-s-timeunit, https://openrefine.org/docs/manual/grelfunctions#date-functions for a table.
date_inc=Returns a date changed by the given amount in the given unit of time, in quotes. See https://openrefine.org/docs/manual/grelfunctions/#incd-n-s-timeunit for a table. The default unit is ''hour''. A positive value increases the date, and a negative value moves it back in time.
date_now=Returns the current time according to your system clock, in the ISO 8601 extended format (converted to UTC). For example, 10:53am (and 00 seconds) on November 26th 2020 in EST returns [date 2020-11-26T15:53:00Z].

# 4. HTML
html_inner_html=Returns the inner HTML of an HTML element. This will include text and children elements within the element selected. Use it in conjunction with parseHtml() and select() to provide an element.
html_parse_html=Given a cell full of HTML-formatted text, parseHtml() simplifies HTML tags (such as by removing '' /'' at the end of self-closing tags), closes any unclosed tags, and inserts linebreaks and indents for cleaner code. A cell cannot store the output of parseHtml() unless you convert it with toString(): for example, value.parseHtml().toString().

# 5. Math
math_abs=Returns the absolute value of a number.
math_acos=Returns the arc cosine of an angle, in the range 0 through PI.
math_asin=Returns the arc sine of an angle in the range of -PI/2 through PI/2.
math_atan=Returns the arc tangent of an angle in the range of -PI/2 through PI/2.
math_atan2=Converts rectangular coordinates (n1, n2) to polar (r, theta). Returns number theta.
math_ceil=Returns the ceiling of a number.
math_combin=Returns the number of combinations for n2 elements as divided into n1.
math_cos=Returns the trigonometric cosine of an angle.
math_cosh=Returns the hyperbolic cosine of a value.
math_degrees=Converts an angle from radians to degrees.
math_even=Rounds the number up to the nearest even integer.
math_exp=Returns e to the power of n.
math_fact=Returns the factorial of a number, starting from 1.
math_factn=Returns the factorial of n1, starting from n2.
math_floor=Returns the floor of a number.
math_gcd=Returns the greatest common denominator of two numbers.
math_lcm=Returns the greatest common denominator of two numbers.
math_ln=Returns the natural logarithm of n.
math_log=Returns the base 10 logarithm of n.
math_max=Returns the greater of two numbers.
math_min=Returns the smaller of two numbers.
math_mod=Returns n1 modulus n2.
math_multinomial=Calculates the multinomial of one number or a series of numbers.
math_odd=Rounds the number up to the nearest odd integer.
math_pow=Returns n1 raised to the power of n2.
math_quotient=Returns the integer portion of a division (truncated, not rounded), when supplied with a numerator and denominator.
math_radians=Converts an angle in degrees to radians.
math_random_number=Returns a random integer in the interval between the lower and upper bounds (inclusively). Will output a different random number in each cell in a column.
math_round=Rounds a number to the nearest integer.
math_sin=Returns the trigonometric sine of an angle.
math_sinh=Returns the hyperbolic sine of an angle.
math_sum=Return the sum of the numbers in the array. Ignores non-number items. Returns 0 if the array does not contain numbers.
math_tan=Returns the trigonometric tangent of an angle.
math_tanh=Returns the hyperbolic tangent of an angle.

# 6. Strings
str_chomp=Returns a copy of string s with string sep remoed from the end if s ends with sep; otherwies, returns s.
str_contains=Returns a boolean indicating whether s contains sub, which is either a substring or a regex pattern. For example, "food".contains("oo") returns true.
str_decode=Decodes a string using the specified encoding. Encodings include Base16, Base32Hex, Base32, Base64, and Base64Url.
str_detect_language=Detects the language of the given string and provides the language code.
str_diff=For strings, takes two strings and compares them, returning a string. Returns the remainder of o2 starting with the first character where they differ. For dates, returns the difference in given time units. See the time unit table at https://openrefine.org/docs/manual/grelfunctions/#datepartd-s-timeunit.
str_encode=Encodes a string using the specified encoding. Encodings include Base16, Base32Hex, Base32, Base64, and Base64Url.
str_ends_with=Returns a boolean indicating whether s ends with sub. For example, "food".endsWith("ood") returns true, whereas "food".endsWith("odd") returns false.
str_escape=Escapes s in the given escaping mode. The mode can be one of: ''html'', ''xml'', csv'', ''url'', ''javascript''. Note that quotes are required around your mode.
str_find=Outputs an array of all consecutive substrings inside string s that match the substring or regex pattern p. You can supply a substring by putting it in quotes. See also match().
str_fingerprint=Returns the fingerprint of s, a string that is the first step in fingerprint clustering methods: it will trim whitespaces, convert all characters to lowercase, remove punctuation, sort words alphabetically, etc.
str_index_of=Returns the first character index of sub as it first occurs in s; or, returns -1 if s does not contain sub. For example, "internationalization".indexOf("nation") returns 5.
str_last_index_of=Returns the first character index of sub as it last occurs in s; or, returns -1 if s does not contain sub. For example, "parallel".lastIndexOf("a") returns 3 (pointing at the second ''a'').
str_match=Attempts to match the string s in its entirety against the regex pattern p and, if the pattern is found, outputs an array of all capturing groups (found in order). See also find().
str_md5=Returns the MD5 hash of an object. If fed something other than a string (array, number, date, etc.), md5() will convert it to a string and deliver the hash of the string.
str_ngram_fingerprint=Returns the n-gram fingerprint of s.
str_ngram=Returns an array of the word n-grams of s. That is, it lists all the possible consecutive combinations of n words in the string.
str_parse_json=Parses a string as JSON.
str_parse_uri=Parses a URI and extracts its components.
str_partition=Returns an array of strings [ a, fragment, z ] where a is the substring within s before the first occurrence of fragment, and z is the substring after fragment. Fragment can be a string or a regex. If omitFragment is true, frag is not returned.
str_phonetic=Returns a phonetic encoding of a string, based on an available phonetic algorithm. Can be one of the following supported phonetic methods: metaphone, doublemetaphone, metaphone3, soundex, cologne. Defaults to ''metaphone3''.
str_range=Returns an array where a and b are the start and the end of the range respectively and c is the step (increment).
str_reinterpret=Returns s reinterpreted through the given character encoders. You must supply one of the supported encodings for each of the original source and the target output: https://docs.oracle.com/javase/1.5.0/docs/guide/intl/encoding.doc.html. Note that quotes are required around character encoders.
str_replace_chars=Returns the string obtained by replacing a character in s, identified by find, with the corresponding character identified in replace. You cannot use this to replace a single character with more than one character.
str_replace_each=Replace each occurrence of a substring in a string with another substring.
str_replace=Returns the string obtained by replacing the find string with the replace string in the inputted string. For example, ''The cow jumps over the moon and moos''.replace(''oo'', ''ee'') returns the string ''The cow jumps over the meen and mees''. Find can be a regex pattern. For example, ''The cow jumps over the moon and moos''.replace(/\\s+/, "_") will return ''The_cow_jumps_over_the_moon_and_moos''
str_rpartition=Returns an array of strings [ a, fragment, z ] where a is the substring within s before the last occurrence of fragment, and z is the substring after the last instance of fragment. If omitFragment is true, frag is not returned.
str_sha1=Returns the SHA-1 hash of an object. If fed something other than a string (array, number, date, etc.), sha1() will convert it to a string and deliver the hash of the string.
str_smart_split=Returns the array of strings obtained by splitting s by sep, or by guessing either tab or comma separation if there is no sep given. Handles quotes properly and understands cancelled characters. The separator can be either a string or a regex pattern.
str_split_by_char_type=Returns an array of strings obtained by splitting s into groups of consecutive characters each time the characters change Unicode categories.
str_split_by_lengths=Returns the array of strings obtained by splitting s into substrings with the given lengths. For example, "internationalization".splitByLengths(5, 6, 3) returns an array of 3 strings: [ "inter", "nation", "ali" ]. Excess characters are discarded from the output array.
str_split=Returns the array of strings obtained by splitting s by sep. The separator can be either a string or a regex pattern. If preserveTokens is true, empty segments are preserved.
str_starts_with=Returns a boolean indicating whether s starts with sub. For example, "food".startsWith("foo") returns true, whereas "food".startsWith("bar") returns false.
str_to_lowercase=Returns string s converted to all lowercase characters.
str_to_title_case=Returns string s converted into titlecase: a capital letter starting each word, and the rest of the letters lowercase. For example, ''Once upon a midnight DREARY''.toTitlecase() returns the string ''Once Upon A Midnight Dreary''.
str_to_uppercase=Returns string s converted to all uppercase characters.
str_trim=Returns a copy of string s with leading and trailing whitespace removed.
str_unescape=Unescapes s in the given escaping mode. The mode can be one of: ''html'', ''xml'', ''csv'', ''url'', ''javascript''. Note that quotes are required around your mode.
str_unicode=Returns an array of strings describing each character of s in their full unicode notation.
str_unicode_type=Returns an array of strings describing each character of s by their unicode type.

# 7. XML
xml_innerxml=Returns the inner XML elements of an XML element. Does not return the text directly inside your chosen XML element - only the contents of its children. Use it in conjunction with parseXml() and select() to provide an element.
xml_owntext=Returns the text directly inside the selected XML or HTML element only, ignoring text inside children elements (for this, use innerXml()). Use it in conjunction with a parser and select() to provide an element.
xml_parent=Returns the parent node or null if no parent. Use it in conjunction with parseHtml() and select() to provide an element.
xml_parsexml=Given a cell full of XML-formatted text, parseXml() returns a full XML document and adds any missing closing tags.
xml_scripttext=Returns the combined data of an HTML/XML Element. Data is e.g. the inside of a <script> tag.\nNote that data is NOT the text of the element.\nUse htmlText() to get the text that would be visible to a user, and scriptText() for the contents of <script>, <style>, etc.\nUse scriptText() in conjunction with parseHtml() and select().
xml_selectxml=Returns an array of all the desired elements from an HTML or XML document, if the element exists. Elements are identified using the Jsoup selector syntax: https://jsoup.org/apidocs/org/jsoup/select/Selector.html.
xml_wholetext=Selects the (unencoded) text of an element and its children, including any new lines and spaces, and returns a string of unencoded, un-normalized text. Use it in conjunction with parseHtml() and select() to provide an element.
xml_xmlattr=Returns a string from an attribute on an XML or HTML element. Use it in conjunction with parseHtml() or parseXml() to point to an element first.
xml_xmltext=Returns a string of the text from within an HTML or XML element (including all child elements), removing tags and line breaks inside the string. Use it in conjunction with parseHtml() or parseXml() and select() to provide an element.

# 8. General
fun_coalesce=Returns the first non-null from a series of objects (meaning any data type - string, date, number, boolean, etc.).
fun_cross=Looks up the given value in the target column of the target project, returns an array of matched rows. Two values match if and only if they have the same string representation. The first argument will be interpreted as cell.value if set to cell. The second argument will be interpreted as the current project name if omitted or set to "". The third argument will be interpreted as the index (starts from 0) column if omitted or set to "".
fun_facet_count=Returns the facet count corresponding to the given choice value, by looking for the facetExpression in the choiceValue in columnName.
fun_get=If o has named fields, returns the field named ''from'' of o. If o is an array, returns a sub-array o[from, to]. if o is a string, returns o.substring(from, to).
fun_has_field=Returns a boolean indicating whether o has a member field called name.
fun_jsonize=Quotes a value as a JSON literal value.
fun_length=Returns the length of string s as a number, or the size of array a, meaning the number of objects inside it. Arrays can be empty, in which case length() will return 0.
fun_slice=Given a string, returns the substring starting from character index from, and up to character index to. If the to argument is omitted, will output to the end of s. Remember character indices start from zero. Given an array, returns a sub-array from the first index provided up to and including the last index provided. If the to value is omitted, it is understood to be the end of the array. Slice only.
fun_time_since_unix_epoch_to_date=Returns a number converted to a date based on Unix Epoch Time. The number can be Unix Epoch Time in one of the following supported units: second, millisecond, microsecond. Defaults to ''second''.
fun_to_date=Returns the inputted object converted to a date object. Without arguments, it returns the ISO 8601 extended format. With arguments, you can control the output format. With monthFirst: set false if the date is formatted with the day before the month. With formatN: attempt to parse the date using an ordered list of possible formats. Supply formats based on the SimpleDateFormat syntax: SimpleDateFormat.
fun_to_number=Returns a string converted to a number. Will attempt to convert other formats into a string, then into a number. If the value is already a number, it will return the number.
fun_to_string=Takes any value type (string, number, date, boolean, error, null) and gives a string version of that value. You can convert numbers to strings with rounding, using an optional string format. See https://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html. You can also convert dates to strings using date parsing syntax. See https://openrefine.org/docs/manual/grelfunctions/#date-functions.
fun_type=Returns a string with the data type of o, such as undefined, string, number, boolean, etc.




© 2015 - 2024 Weber Informatics LLC | Privacy Policy