Tag Archives: Google Apps Script

Upload CSV Files to BigQuery with Apps Script

I have written a Google Apps Script that will automatically upload data from one or more files in your Google Drive to your BigQuery table. This script looks for CSV file in a particular Drive Folder, uploads them to BigQuery tablet and then moves the file to another folder in Drive to indicate that it has been processed.

You need to have a table read in your BigQuery dataset and the BigQuery API needs to be enabled inside the Google Developer Console. If you are getting errors, you probably need to enable the Billing option under the BigQuery API settings. You won’t be charged but the credit cards needs to be added for you to create datasets and tables inside BigQuery.

Generate List of all Files in a Google Drive Folder

This is like running the ls Linux command for listing all the files and their details in a particular Google Drive folder. Call the listFiles method with the Drive folder name and it will create a list of all files and appends them to a spreadsheet. The direct download links are particularly handy for downloads PDFs and other non Google Docs documents. Credit: @hubgit.

Combine Multiple RSS Feeds with Google Scripts

This Google Script takes 2 or more RSS feeds and mashes them up into a JSON feed that you can call from an external app by publishing the script as a web app. Internally, the script uses URLFetchApp to fetch the XML feed and parses it using the Xml service.

This can also be used for single widgets that output data from multiple RSS feeds. You can also mix and mashup RSS feeds with Yahoo Pipes.

Color Codes for Google Spreadsheets

This Google Script converts the currently active Google Spreadsheet into a square grid of randomly colored boxes using hexadecimal numbers. Credit 五味田和則

The random colors are generated using a JavaScript method – Math.ceil(Math.random() * 0xFFFFFF).toString(16). Also, since the value of the cell is the same as the color code, you can copy a cell to copy its color code.

Decode Base64 Email with Apps Script

You can decode base64 encoded email messages in Gmail, or files in your Google Drive, using the base64Decode() method of Google Apps Script.

Iterate through Google Drive Folders and Files

The Google Script will iterate through all files and folders in your Google Drive and lists the file names and the folder names inside the console. You may to use the Folder Iterator if you have too many files in the Drive else the script will exceed the allotted execution time.