tanaike

The Thinker

Replacing Values in Cells on Google Spreadsheet using Google Apps Script

Gists This is a sample script for replacing values in the cells on Google Spreadsheet using Google Apps Script. Sample situation The sample situation is as follows. Sample script This sample script used Sheets API. So, please enable Sheets API at Advanced Google services. function myFunction() { const obj = { sample1: "ab", sample2: "cd", sample3: "ef", sample4: "gh", sample5: "ij", sample6: "kl", sample7: "mn", sample8: "op", sample9: "qr", }; const ss = SpreadsheetApp.

Uploading Files to Google Drive with Asynchronous Process using Python

Gists This is a sample script for uploading files to Google Drive with asynchronous process using Python. Sample script import aiohttp import asyncio import json folder_id = "###" # Please set the folder ID you want to put. token = "###" # Please set your access token. url = "https://www.googleapis.com/upload/drive/v3/files" async def workers(file): async with aiohttp.ClientSession() as session: metadata = {"name": file["filename"], "parents": [folder_id]} data = aiohttp.

Parsing JSON Data Array by Expanding Header Row using Google Apps Script

Gists This is a sample script for parsing JSON data array by expanding the header row using Google Apps Script. Sample script function myFunction() { const obj = [ { key1: "value1", key2: "value2", key3: "value3" }, { key4: "value1", key5: "value2", key6: "value3" }, { key7: "value1", key8: "value2", key9: "value3" }, ]; const headers = Object.keys( obj.reduce((o, e) => (Object.keys(e).forEach((k) => (o[k] = true)), o), []) ); const values = [headers, .

Exporting Tabulator Data to Google Drive using Google Apps Script

Gists This is a sample script for exporting the Tabulator data to Google Drive using Google Apps Script. As the sample, a dialog on Google Spreadsheet is used. So, please copy and paste the following scripts to the container-bound script of Google Spreadsheet. Google Apps Script side: Code.gs const saveFile = (e) => DriveApp.createFile(Utilities.newBlob(...e)).getId(); // Please run this script. const openDialog = (_) => SpreadsheetApp.getUi().showModalDialog( HtmlService.createHtmlOutputFromFile("index"), "sample" ); HTML & Javascript side: index.