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.
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('::')
Related
I want extract text values from every sub objects the given JSON structure . For do that I have used following JMSEPath query translations.en.*[0].[*].children.text but I was not unable to extract the value . Can someone suggest me a correct query or other approches
It may be better if you add to the question the expected output as well.
Making a big assumption that you want all text values "flatten up" into a single array you can try this: translation.en.*[].children[].text
Ref https://jmespath.org/tutorial.html#flatten-projections
I'm trying to target the number of search results on our website for each search term so that I can see how many results each one pulls in.
I'm working off of this article, but I can't get the javascript function correct to pull out the number (which could be as high as 2000) and put it into a variable.
<div class="search-results-text"><strong>732 results</strong> found for ‘<strong>search term</strong>’</div>
Hoping someone can help me out with the javascript function that would grab that number before "results". Thanks!
You would probably get away with a custom Javascript variable like this:
function() {
return document.querySelector('.search-results-text strong').innerText.split(" ")[0];
}
The querySelector with the CSS selector gets the Element, innerText is the text without the markup, the split splits the string up by whitespace, which gives you an array, and the first element of that array is your number (array are index starting with zero, so [0] refers to the first element).
This is not particularly elegant (for one you probably want to add some sort of error handling), and you could actually replace document.querySelector('.search-results-text strong').innerText with a DOM type variable in GTM (which by default returns the text of the element).
I don't think you can get the number with CSS selectors alone.
I am struggling to find anything on the internet related to this one.
You can easily name a range in excel and it's treated as an array.
An example would be the average formula. You can feed a list from a named range into the formula.
Named Range "list" contains the values:
1,2,3,4,5,6,7,8,9,10
Named Range "list2" contains the values:
2,3,4,5,6,7,8,9,10,11
Currently in excel, this is possible.
=Average(Number1,[Number2], ...)
=Average(List1,List2)
Would it be possible to do ->
Average(list[1],list[6])
I want this to make my formulas more simple.
I have a large list of people and instead of doing
B1!H4, B1!h5
I would love to do N[1], N[2], N[3]
Thank you all!
google-spreadsheet
You can use INDEX():
=AVERAGE(INDEX(list,1),INDEX(list,6))
Where list is a named range.
I’ve been trying to figure out how to write a script which will take the value from one cell and append it to the end of a string of numbers in another cell of that same row. The newly appended number needs to be separated by a comma from the previously appended value, and the whole string needs to be wrapped between brackets. EX. [2,3,3,4.5,2.5,2.1,1.3,0.4]. The script will need to loop through all of the rows containing data on a named sheet beginning with the third row.
The above image is obviously just an example containing only two rows of data. The actual spreadsheet will contain well over a thousand rows, so the operation must be done programmatically and will run weekly using a timed trigger.
To be as specific as I can, what I need help with is to first know if something like the appending is even possible in Google App Scripts. I've spent hours searching and I can't seem to find a way to append a new value (ex. cell A3) to the current string (ex. cell B3) without overwriting it completely.
In full disclosure; I'm a middle school teacher trying to put something together for my school.
To be as specific as I can, what I need help with is to first know if something like the appending is even possible in Google App Scripts.
Seeing the expected result, it's inserting rather than appending, as the string should be added before the last character (]). Anyway, yes, this is possible by using JavaScript string handling methods.
Use getValue() to the get the cell values, both the Current GPA and the GPA History.
One way is to use replace
Example using pure JavaScript:
var currentGPA = 3.5
var gpaHistory = '[2,3.1,2.4]';
gpaHistory = gpaHistory.replace(']',','+currentGPA+']');
console.info(gpaHistory)
Once you get the modified gpaHistory, use setValue(gpaHistory) to add this value to the spreadsheet.
I am returning a query object from Coldfusion as a JSON string which I then parse into JSON in Javascript. It has a bit of a strange format when I finally log it though.
I am faced with two problems. First, I do not know how to access the lowest element (i.e Arthur Weasley) as I cannot use a number in my selector (response.DATA[0].0 doesn't work because the lowest field name is a number). Second, is there any way to assign the values in the columns section to the fields that are numbered 1, 2 and 3?
What I'm really asking is how do I select my lowest level of data? If that can't be done because of the numbers for field names, how do I change the names to something more fitting?
My data logged:
First entry of first entry of DATA = response.DATA[0][0]
So
name = reponse.DATA[0][0];
trainsThing = response.DATA[0][1];