sadfasdf2 / google-refine

Automatically exported from code.google.com/p/google-refine
Other
0 stars 0 forks source link

Preview result and real result mismatch #434

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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 reported on code.google.com by ocean.ch...@gmail.com on 13 Aug 2011 at 5:35

GoogleCodeExporter commented 9 years ago

Original comment by dfhu...@gmail.com on 13 Aug 2011 at 11:27

GoogleCodeExporter commented 9 years ago

Original comment by dfhu...@gmail.com on 14 Aug 2011 at 12:29

GoogleCodeExporter commented 9 years ago
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. 

Original comment by ocean.ch...@gmail.com on 14 Aug 2011 at 12:53

GoogleCodeExporter commented 9 years ago
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.

Original comment by dfhu...@gmail.com on 20 Sep 2011 at 9:15

GoogleCodeExporter commented 9 years ago
Post 2.5.

Original comment by dfhu...@gmail.com on 20 Sep 2011 at 9:28

GoogleCodeExporter commented 9 years ago
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 ??

Original comment by thadguidry on 20 Sep 2011 at 2:00

GoogleCodeExporter commented 9 years ago

Original comment by tfmorris on 18 Sep 2012 at 6:00

GoogleCodeExporter commented 9 years ago
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(":::")

Original comment by thadguidry on 18 Sep 2012 at 7:11