Skip to content

Instantly share code, notes, and snippets.

View tanaikech's full-sized avatar

Kanshi TANAIKE tanaikech

View GitHub Profile
@tanaikech
tanaikech / file0.txt
Last active January 20, 2017 08:24
コマンドラインからローカルPCまたはweb上の画像データを使ってGoogleの類似画像検索を行う ref: http://qiita.com/tanaike/items/dd89e41bf77bc3d96f51
$ python スクリプト.py -f ファイル名
@tanaikech
tanaikech / file0.txt
Last active January 28, 2018 09:50
Google Apps Scriptを使用したGoogle Drive上のファイル移動 ref: http://qiita.com/tanaike/items/1d3b2cac43cf5c34e9f7
var sourcefile = [コピー元ファイル名]; // file name
var destfolder = [コピー先フォルダ名]; // folder name
var destfolder = DriveApp.getFoldersByName(destfolder).next();
var file = DriveApp.getFilesByName(sourcefile).next();
var sourcefolder = file.getParents().next();
destfolder.addFile(file);
sourcefolder.removeFile(file);
@tanaikech
tanaikech / submit.md
Created June 15, 2017 04:46
Retrieving User Information with Shared Spreadsheet

Retrieving User Information with Shared Spreadsheet

This sample script retrieves the user information which is editing the shared spreadsheet.

It was found as follows.

  • User information retrieving by Class Session is the owner and users which installed triggers by themselves.
  • When each user installs a trigger, user information retrieving by Class Session losts the accuracy. So user information has to be retrieved using a temporally installed trigger.
  • Using onOpen(), it cannot directly install triggers and authorize.
  • Using menu bar, it can install triggers and authorize Google Services using API.
@tanaikech
tanaikech / submit.md
Created June 15, 2017 04:48
OCR using Google Drive API

OCR using Google Drive API

This is a sample script for OCR using Google Drive API. A text file which converted by OCR can be retrieved by inputting an image file.

In this sample, Python Quickstart is used. The detail information is https://developers.google.com/drive/v3/web/quickstart/python. Please read “Step 1: Turn on the Drive API” and “Step 2: Install the Google Client Library”.

from __future__ import print_function
import httplib2
import os
@tanaikech
tanaikech / submit.md
Created June 15, 2017 04:50
Retrieve old revision file from Google Drive

Retrieve old revision file from Google Drive

I introduce 2 kinds of methods. One is to use curl. Another is to use wget. At this time, I could know that wget can be also used as same as curl.

In order to use this, at first, please retrieve your access token and enable Drive API.

1. File ID

Retrieve file id from file name.

@tanaikech
tanaikech / submit.md
Created June 15, 2017 04:52
Embedding a Chart to a Cell using Custom Function on Spreadsheet

Embedding a Chart to a Cell using Custom Function on Spreadsheet

This sample script embeds a chart to a cell using custom function on Spreadsheet.

I think that this method is one of various ideas.

Problem

When you want to create a chart and embed it to a cell using custom functions, you notice that insertChart() cannot be used. There are some limitations for using custom functions. But insertChart() creates floating charts. So in order to embed a chart to a cell, the function =IMAGE() is suitable for this situation. Here, setFormula() for setting =IMAGE() and DriveApp.createFile() for creating images from charts also cannot be used for custom functions.

Solution

@tanaikech
tanaikech / submit.md
Created June 15, 2017 04:54
Changing Line to Bars for Combo Chart using GAS

Changing Line to Bars for Combo Chart using GAS

Sample data

This is a sample data for this sample script. The column B was created by the normal distribution formula, and the column C was created by multiplying random number for column B.

A, B, C
1.0, 0.0001, 0.0000
1.5, 0.0009, 0.0006
2.0, 0.0044, 0.0037
@tanaikech
tanaikech / submit.md
Created June 15, 2017 04:55
Embedding a Map to a Cell using Custom Function on Spreadsheet

Embedding a Map to a Cell using Custom Function on Spreadsheet

This sample script embeds a map to a cell using custom function on Spreadsheet.

I think that this method is one of various ideas.

Problem

When the map is embeded to a cell on spreadsheet as an image, the function =IMAGE() is suitable for this situation. However, setFormula() for importing =IMAGE() and DriveApp.createFile() for creating images from maps also cannot be used for custom functions.

Solution

@tanaikech
tanaikech / submit.md
Created June 15, 2017 04:56
OCR using Custom Function on Spreadsheet

OCR using Custom Function on Spreadsheet

This sample script performs OCR and imports resultant text to a cell using custom function on Spreadsheet.

Drive API has a function to do OCR. It was used for this sample.

I think that this method is one of various ideas.

Problem

When OCR is performed and imported the result to a cell on spreadsheet, there are some limitations. DriveApp, UrlFetchApp, setFormula() cannot be used for custom functions.

@tanaikech
tanaikech / submit.md
Created June 15, 2017 04:57
Embedding Animation GIF in A Cell on Spreadsheet

Embedding Animation GIF in A Cell on Spreadsheet

This sample script is for embedding animation GIF in a cell using custom function on Spreadsheet.

I think that this method is one of various ideas.

Problem

There are some limitations.

  1. Images of jpeg and png can be embedded in a cell using =IMAGE(). But when animation GIF is embedded using it, GIF is not played.