OpenRefine icon indicating copy to clipboard operation
OpenRefine copied to clipboard

Preview result and real result mismatch

Open tfmorris opened this issue 13 years ago • 5 comments

Original author: [email protected] (August 13, 2011 17:35:25)

When I parseJson certain columns, the Preview window shows me one result, but when I press OK to apply the column returns a blank result instead.

What steps will reproduce the problem?

  1. Apply Expression: forEach(value.parseJson()['keywords'], v, v['text'])

To cell containing: { "status": "OK", "url": "", "language": "english", "keywords": [ { "text": "York en route", "relevance": "0.974363" }, { "text": "Anthony Eden", "relevance": "0.814394" }, { "text": "President Eisenhower", "relevance": "0.700189" }, { "text": "friendship treaty", "relevance": "0.647907" }, { "text": "Prime Minister", "relevance": "0.6367" }, { "text": "large section", "relevance": "0.580594" }, { "text": "Washington", "relevance": "0.442583" }, { "text": "Russia", "relevance": "0.22313" } ] }

What is the expected output? Preview window shows result will be: [ "York en route", "Anthony Eden", "President Eisenhower", "friendship treaty", "Prime Minister", "large section", "Washington", "Russia" ]

What do you see instead? blank cells

What version of Google Refine are you using? 2.1

What operating system and browser are you using? Mac 10.6.8 Safari and Firefox

Is this problem specific to the type of browser you're using or it happens in all the browsers you tried? In both Safari and Firefox

Original issue: http://code.google.com/p/google-refine/issues/detail?id=434

tfmorris avatar Oct 15 '12 03:10 tfmorris

From [email protected] on August 14, 2011 00:53:51: I've learned that adding .join(", ") to the end of the expression remedies this issue - in case anyone else has run into this problem. But it would be helpful if Google Refine did not allow a preview of results that will not be reflected when an expression is applied. Thank you to everyone who helped me solve this problem.

tfmorris avatar Oct 15 '12 03:10 tfmorris

From [email protected] on September 20, 2011 09:15:27: The challenge here is that the result of the expression is not a single serializable value (that can be stored into a single cell). But we still want to preview it so that the user knows how to extend the expression further to convert that value into something storable.

Maybe the preview UI should indicate which values are storable and which are not. I'm not sure if that's understandable.

tfmorris avatar Oct 15 '12 03:10 tfmorris

From [email protected] on September 20, 2011 09:28:05: Post 2.5.

tfmorris avatar Oct 15 '12 03:10 tfmorris

From thadguidry on September 20, 2011 14:00:36: I still say we use color coding here (like the example I emailed you David), & also label the column header in the expression editor to tell the user what value type will be output into the cells... if nothing, then say "NOTHING WILL OUTPUT" in big bold red flashing letters, lolol. Or perhaps just tool tip a label "OUTPUT PROBLEM, HOVER HERE" to breakdown the scenario with different value types and give more useful explainations. OR make that Red label "OUTPUT PROBLEM, CLICK HERE", be a clickable link that takes them to helpful pages on the wiki ??

tfmorris avatar Oct 15 '12 03:10 tfmorris

From thadguidry on September 18, 2012 19:11:47: I've updated our function docs to show how to combine forEach() with parseJson() to get all named object instances in a JSON array. http://code.google.com/p/google-refine/wiki/GRELOtherFunctions#parseJson(string_s)

There might be a case to make it easier to do with better sugar syntax however, such as value.parseJson().keywords.text.join(":::")

tfmorris avatar Oct 15 '12 03:10 tfmorris