-
Notifications
You must be signed in to change notification settings - Fork 0
/
googlesheet.js
39 lines (29 loc) · 1.02 KB
/
googlesheet.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const GoogleSpreadsheet = require('google-spreadsheet');
const { promisify } = require('util');
const creds = require('./client_secret.json');
function printStudent(student) {
console.log('Name: ' + student.studentname);
console.log('Major: ' + student.major);
console.log('Home: ' + student.homestate);
console.log('--------------------------------------');
}
async function accessSpreadsheet() {
const doc = new GoogleSpreadsheet('1h0t_SxjxZdWLtKfChwu9twoOozNyzB333yATyNHsfa8');
await promisify(doc.useServiceAccountAuth)(creds);
const info = await promisify(doc.getInfo)();
const sheet = info.worksheets[0];
//console.log('Tittle: ' + sheet.title, 'Rows: ' + sheet.rowCount);
const rows = await promisify(sheet.getRows)({
offset: 1,
limit: 1,
//orderby: 'homestate',
//query: 'homestate = AK',
});
//console.log(rows)
rows.forEach(row => {
row.homestate = 'MD';
row.save();
printStudent(row);
});
}
accessSpreadsheet();