Search code examples
jsongoogle-apps-scriptgoogle-sheetscustom-function

Retrieve a subset of data using ImportJSON custom function


I'm using Trevor Lohrbeer's importjson() custom function to import some data from this JSON source into a Google Sheet.

I don't want all of the information provided; I specifically only want columns E, V, W, X, AA, AB, AC, AD.

I tried a few things before realizing I have no idea what I'm doing with this parameter:

=importjson("http://www.pgatour.com/data/r/stats/current/102.json","This","AndThis")

How can I modify this function to retrieve only the items mentioned above?


Solution

  • You can do this easily using the QUERY function, post-filtering the results of the importjson() call.:

    =QUERY(importjson("http://www.pgatour.com/data/r/stats/current/102.json"),"select Col5, Col22, Col23, Col24, Col27, Col28, Col29, Col30")