Replies: 1 comment 1 reply
-
@SimplGy Here's a snippet I use in one of my scripts you can try out: https://www.npmjs.com/package/google-spreadsheet let { GoogleSpreadsheet } = await npm("google-spreadsheet")
let doc = new GoogleSpreadsheet("spreadsheet-id") // spreadsheet id from the URL
// read out getting an email/key here: https://www.npmjs.com/package/google-spreadsheet
let client_email = await env("GOOGLE_CLIENT_EMAIL")
let private_key = (await env("GOOGLE_PRIVATE_KEY")).replace(/\\n/g, '\n')
await doc.useServiceAccountAuth({
client_email,
private_key
})
await doc.loadInfo()
let sheet = doc.sheetsByIndex[0]
let rows = await sheet.getRows()
let headers = sheet.headerValues
let data = {}
for await (let h of headers) {
data[h] = []
}
for (let row of rows) {
for (let h of headers) {
let value = row[h]
if (value) {
data[h].push(value)
}
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Anyone had any luck with "getting data" from Google Sheets?
Fiddled around a little bit; looks like the approaches are:
Beta Was this translation helpful? Give feedback.
All reactions