Back to the Shapespark home page

Use google spreadsheet to update data in the model

Hello!

I manage to write a script that might be useful for other users.
It gets data from an external Spreadsheet and input in the Shapespark model.
In my case I make models from people that sell apartaments.
To update price values and other information it became easier to update directly by spreadsheet than upload the model everytime something changes.
No need for API Keys.

  1. Create a Google Spreadsheet. Input the data. Make it public to view. Get the sheet ID.

  2. Use the script below:

  1. Below one model as example. I used the values from the table for location and money calculations of the apartament
3 Likes

async function getData() {

const ID = “1QUmXix5ZU78aM8uZ1QcuHWSlrDWDJQw67AruPtW1e8w”
// Use your own ID. Replace it in the URL.
const ROW = 2
const COL = 19
const URL = “https://spreadsheets.google.com/feeds/cells/1QUmXix5ZU78aM8uZ1QcuHWSlrDWDJQw67AruPtW1e8w/default/public/full?min-row="+ROW+"&min-col=1&max-col="+COL+"&alt=json

// In this case I get information from row 2, column from 1 to 19.

const response = await fetch (URL);
const data = await response.json();

// [0] to [10] gets the column 1 to 9.

const Apartamento = parseFloat(data.feed.entry[0].gs$cell.inputValue)
const Price = parseFloat(data.feed.entry[1].gs$cell.inputValue)
const Rent = parseFloat(data.feed.entry[2].gs$cell.inputValue)
const AveragePrice = parseFloat(data.feed.entry[3].gs$cell.inputValue)
const OcupationRate = parseFloat(data.feed.entry[4].gs$cell.inputValue)
const OperationCosts = parseFloat(data.feed.entry[5].gs$cell.inputValue)
const ManagementFee = parseFloat(data.feed.entry[6].gs$cell.inputValue)
const SquareMeter = parseFloat(data.feed.entry[7].gs$cell.inputValue)
const Location = data.feed.entry[8].gs$cell.inputValue
const LatLong = data.feed.entry[9].gs$cell.inputValue
const PageLink = data.feed.entry[10].gs$cell.inputValue

1 Like