tanaike - Google Apps Script, Gemini API, and Developer Tips

The Thinker

Add next row to current row using AWK

File.txt : a1 a2 a3 a4 a5 a6 Code : awk '{array[NR]=$0} END {for (i in array) {if (i>1) {{print array[i-1]","array[i]}}}}' File.txt Result : a1,a2 a2,a3 a3,a4 a4,a5 a5,a6 After the all rows are imported to an array, it shows next row to current row under a condition of row > 1.

Retrieving cells without blank using GAS

This is a sample script for retrieving cells without blank cells. Figure 1 shows the sample spreadsheet. In this sheet, the row 14 has one space. Fig. 1: Sample spreadsheet. Data is retrieved as follows. var data = SpreadsheetApp .getActiveSpreadsheet() .getActiveSheet() .getRange('a1:a30') .getValues(); 1. Retrieving cells with spaces and no blank cells. var Result = [i for each (i in data)if (i)].

One Liner Code for Netatmo

I made One Liner Code to retrieve data using Netatmo API. There are 2 ways. One is for windows dos. Another is for unix bash. Requirement tools are curl and jq. windows dos > setlocal & curl -s -d "grant_type=password&client_id='#####'&client_secret='#####'&username='#####'&password='#####'&scope=read_station" "https://api.netatmo.net/oauth2/token" | for /f "usebackq tokens=*" %a in (`jq -r ".access_token"`) do @set a="%a" | curl -s -d "access_token=%a&device_id='#####'" "https://api.netatmo.net/api/getstationsdata" > dat.txt & for /f "usebackq tokens=*" %b in (`jq -r ".

Python Library - souwapy

This “souwapy” is a library for summing array elements with high speed by new algorithm (Pyramid method). The speed is faster than csv and panbdas module of python and v8 engine of node.js. The souwapy module is 2.3 and 3.1 times faster than csv and pandas module, respectively. This was really surprised me. It was found that the theory was correct. At first, I have created this theory for Google Apps Script.

Element's Duplicate Number in Array at Python

Suddenly I had to need this. This script can get the duplicate number of each element in array at Python. In this script, the duplicate number of each element is obtained and sorted by the duplicate number. This was expressed by the comprehension. data = ['a', 'b', 'c', 'd', 'b', 'c', 'd', 'b', 'c', 'b'] result = sorted({i: data.count(i) for i in set(data)}.items(), key=lambda x: x[1], reverse=True) print(result) >>> [('b', 4), ('c', 3), ('d', 2), ('a', 1)]