Alistair Goulding
Alistair Goulding

Reputation: 41

Import JSON data into single cell in google sheets

I am wondering if anyone can give me an example on how to gather data from a JSON file, and import it into a single cell in google sheets? It does not need to be formatted or copied to multiple cells, it simply needs to take the entire contents of the JSON and copy it into a single cell. The file I am working with is also a local file. Can anyone shed some light? It does not necessarily need to use google apps script, if a python script or anything similar could do the same thing that would be ok

Upvotes: 3

Views: 2273

Answers (2)

Abdullah Ahmad
Abdullah Ahmad

Reputation: 70

You can also use an extension of "API CONNECTOR" for free in the google sheets and just paste the url of the json file you need to import. here is the link to the API Connector extension https://workspace.google.com/marketplace/app/api_connector/95804724197 here is how to perform it. https://www.benlcollins.com/apps-script/api-tutorial-for-beginners/

Upvotes: 0

user3717023
user3717023

Reputation:

First of all, Google Sheets cannot access your local files. It's a web application, so any external data it gets must be accessible from the Internet.

If your goal is simply to put the contents of a web-accessible JSON file in a single cell, the following custom function will do the job:

function import(url) {
  return UrlFetchApp.fetch(url).getContentText();
}

This simply grabs whatever page you point at, and crams its contents in a cell. Example: =import("http://xkcd.com/info.0.json")


If you do decide to parse JSON, be advised there isn't anything suitable built into Google Sheets at present. The project importJSON by Trevor Lohrbeer may be helpful.

Upvotes: 2

Related Questions