I have the results from Google place details. I would like to parse the phone number out of it. How could I do so? I am using OpenRefine and using fetching column on the basis of another column.
Asked
Active
Viewed 479 times
-3
-
1Some interesting readings on [how to ask a good question on StackOverflow](https://stackoverflow.com/help/how-to-ask) and [how to parse a JSON in Open Refine](https://stackoverflow.com/questions/10304238/parse-json-in-google-refine). To keep it short and simple : Why do you post a bad and useless screenshot rather than copy and paste your JSON? – Ettore Rizza Jun 27 '17 at 03:20
-
Confidential info , unfortunately. Thank you Ettore, i would make use of the the document on how to ask a good question. – Vijay Jun 27 '17 at 07:35
1 Answers
0
Here is an example of Google Place JSON.
As you can see, "formated_phone_number" is a direct child of "result". In Open Refine, you can extract this element using the following GREL formula:
value.parseJson().result.formatted_phone_number
If there are more than one phone number, use a for
loop to iterate over the array. The syntax in Open refine is:
forEach(value.parseJson().result, x, x.formatted_phone_number)
(x is a variable name, you can use it or what you want instead.)
The result will be an array. Since an Open Refine column can only display strings, numbers and dates, you must convert the array to string using the join function (and a delimiter of your choice).
forEach(value.parseJson().result, x, x.formatted_phone_number).join('::')

Ettore Rizza
- 2,800
- 2
- 11
- 23