Skip to content

Instantly share code, notes, and snippets.

@timtomch timtomch/GetPrice.json
Last active Apr 3, 2017

What would you like to do?
OpenRefine operations to get minimum price data from
"op": "core/column-addition-by-fetching-urls",
"description": "Create column ISBNdb Price at index 2 by fetching URLs based on column pISBN using expression grel:\"\"+toString(floor(value))",
"engineConfig": {
"mode": "row-based",
"facets": []
"newColumnName": "ISBNdb Price",
"columnInsertIndex": 2,
"baseColumnName": "pISBN",
"urlExpression": "grel:\"\"+toString(floor(value))",
"onError": "set-to-blank",
"delay": 5000
"op": "core/text-transform",
"description": "Text transform on cells in column ISBNdb Price using expression grel:if(toNumber(value.parseJson()[\"result_count\"])>0,sort(forEach(value.parseJson()[\"data\"],resp,resp.parseJson()[\"price\"]))[0],Null)",
"engineConfig": {
"mode": "row-based",
"facets": []
"columnName": "ISBNdb Price",
"expression": "grel:if(toNumber(value.parseJson()[\"result_count\"])>0,sort(forEach(value.parseJson()[\"data\"],resp,resp.parseJson()[\"price\"]))[0],Null)",
"onError": "keep-original",
"repeat": false,
"repeatCount": 10

This comment has been minimized.

Copy link
Owner Author

timtomch commented Aug 13, 2015

This JSON can be applied to any OpenRefine project, by using the "Replaying Operations" feature.

Some things to consider

  1. This looks for a column called pISBN for ISBNs to search for. Change accordingly if the column containing ISBNs in your project has a different name.
  2. You will need to register with ISBNdb in order to get an API key. Replace the string YOURKEY above with the key you will receive.
  3. These operations do not apply any facets. They will therefore happily process all the rows in your file. If you have a large file, this is likely to exceed the number of calls to the API you are allowed to make in a day. Consider splitting your file first, e.g. by using facets.

What do these operations do?

The first operation queries the ISBNdb Prices API, searching by the ISBN provided in the input column (pISBN). The JSON data returned is then stored into a new column called ISBNdb Price.

The second operation processes the returned JSON data to compute the minimum price returned for each title. If the API call returned no result, the value is set to Null for this row.

Have fun!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.