Last active
May 5, 2021 13:46
-
-
Save himkt/ed32398b5f368261ceedc4120093bb8e to your computer and use it in GitHub Desktop.
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
var sheetId = "Your_sheet_id"; | |
var sheetName = "Forrm_tab_name"; | |
var schema = { | |
timeStamp: 0, | |
title: 3, | |
authors: 2, | |
isRead: 1, | |
sourceShort: 4, | |
year: 5, | |
paperLink: 6, | |
keywords: 8, | |
note: 7, | |
paperType: 10, | |
issueLink: 11, | |
source: 12, | |
}; | |
function toDict (row) { | |
var item = {} | |
for (var key in schema) item[key] = row[schema[key]]; | |
return item; | |
}; | |
function fetchPapers() { | |
var paperListSpreadSheet = SpreadsheetApp | |
.openById(sheetId) | |
.getSheetByName(sheetName); | |
var paperList = paperListSpreadSheet.getDataRange().getValues().map(function(row, index) { | |
if (index == 0) return; // header | |
return toDict(row); | |
}).filter(function(ret) { return ret != null} ); | |
Logger.log(paperList); | |
return JSON.stringify(paperList); | |
} | |
function doGet() { | |
const paperListJson = fetchPapers(); | |
return ContentService.createTextOutput(paperListJson); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment