Last active
July 2, 2020 23:00
-
-
Save guilhermecomum/cbaa45980e8dffa78451edaaeafb12de to your computer and use it in GitHub Desktop.
Google Spreadsheet to JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const data = require("./googlespreadsheet.json"); | |
var columns = []; | |
var rows = {}; | |
for (var i = 0; i < data.feed.entry.length; i++) { | |
var entry = data.feed.entry[i]; | |
var value = entry.content.$t; | |
var row = entry["gs$cell"]["row"]; | |
var col = entry["gs$cell"]["col"]; | |
var key = columns[col - 1]; | |
var newRow = {}; | |
if (entry["gs$cell"]["row"] === "1") { | |
columns.push(value); | |
} else { | |
rows[row] = { ...rows[row], [key]: value }; | |
} | |
} | |
rows = Object.values(rows); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment