Loading public JSON data into Google Sheets in 67 lines of code
I realized lately that I want to mess around with visualizations in Google Data Studio, but I want it to be with data that I understand. That way, I can more easily tell if there’s something wrong or needing adjustment.
So…i figured i’d write up a super quick method of getting data into Google Sheets from one of the public APIs available. I looked around on https://github.com/public-apis/public-apis and noticed there was University information available via https://github.com/Hipo/university-domains-list, and even better, the actual JSON file was available too:
Of course, this method would work with any JSON data, but having it already available in a public file definitely simplified things.
Here’s how I did it in just a few lines of code:
- Grab the JSON data from the URL
- Parse it using the built-in appscript helpers
- Loop through the data, creating a “row” to be added to a Google Sheet for each domain
- After a certain number of rows, write the results to the sheet to help avoid any memory limit issues.
- Write any remaining rows to the sheet
- That’s it!
Once the data is in there, it’s pretty straight forward to throw a quick datastudio dashboard together to do some digging & experimenting.
Repo code shared here:
Hopefully this helps people easily get some sample data together without having to write a lot of code.