AppsScriptPulse

Use Google Sheets Apps Script to track Open Source GitHub and Docker statistics

Image credit: Codenotary

If you run and maintain an Open Source project you’ll typically will want to keep track of things like your downloads, stars, commits over time, etc. to help you gauge engagement and overall health of your project. Here’s a quick way hack to keep track of some of this data in Google Sheet which will help you simplify the collection of data and help you better understand what that data means for your project.

This post was picked up by the official @WorkspaceDevs Twitter account, which has been highlighting and amplifying more community contributions recently (hint: you may want to follow/tag the account :)

The two things that caught my eye in this post. First, was the pattern used to get stats from multiple GitHub repos which are all appended in the same row (repo 1 cols B-F and repo 2 cols G-H).

Image credit: Codenotary

As a bit of a REST API/auth geek the second thing that interested me was the use of the Accept header, used by GitHub to specify the REST API version being called in UrlFetchApp.

Source: Use Google Sheets Apps Script to track Open Source GitHub and Docker statistics

Email notification of Drive file changes within last x hours

Periodically check for any changes in a given Google Drive file and receive an email notification if there are any, within your given time-frame.

Email notification of Drive file changes. Image credit: Phil Bainbridge

The following Google Apps Script is designed to periodically check for any changes that have occurred to a given Google Drive file (ie edits to it) and send an email to notify of that. It goes through the Revision (Version History) of the file and looks at the modification dates for those that match with your given timeframe, to then collect the Username & Email address of the person that made those edits for inclusion in the email.

So as an example you may have a Google Sheet where you want to setup a check every 4 hours, to then be emailed if there have been any edits to it, along with who made those edits.

Source: The Gift of Script: Email notification of Drive file changes within last x hours

Importing data from MS Excel to Google Sheet with Google Apps Script

In this post we’re going to look at how we can get data from an Excel spreadsheet and import some of it into a Google Sheet. As an example, we’re going to upload an Excel which contains the current month’s royalty data from Amazon and add it to a central sheet which contains all the previous month’s royalties.

Similar to the post on converting a PDF document to text, this tutorial from Baz Roberts uses a similar approach of using the Google Drive API for file conversion, this time converting a MS Excel file into Google Sheets to make it possible to easily extract and update a master spreadsheet. The post includes a detailed explanation of the shared code.

Source: Importing Amazon royalty data from Excel to Google Sheet – Learning Google Workspace & Apps Script

How to extract text from PDF files with Google Apps Script – Digital Inspiration

Image credit: Amit Agarwal

This tutorial explains how you can parse and extract text elements from invoices, expense receipts and other PDF documents with the help of Apps Script.

We’ve previously featured a method for extracting text from a PDF from Scott Donald. This latest post from Amit Agarwal uses a similar technique of sending a PDF document to Google Drive API to convert to a text file and then using RegEx to extract the content you need. Given the number of PDF documents flying around between organisations both of these posts from Amit and Scott are worth being aware of for potential future projects.

Source: How to Extract Text from PDF Files with Google Apps Script – Digital Inspiration

See your Google Calendar events in Google Maps using Google Apps Script

Image credit: KEVIN VAGHASIYA

In this article, I will show you how can you visualize google calendar events in the google maps using Google Calendar, Maps Javascript API, HTML, CSS and Google Apps Script.

This is an interesting project shared by Kevin Vaghasiya which uses Google Apps Script to create a web app to display a range of Google Calendar events on a map. On the backend the script is using the Maps Service and geocode(address) to get the co-ordinates of the event location. This could be an interesting project to modify to send yourself a daily email with a static map image of your appointments.

Source: See your calendar events in Google Maps using Google Apps Script

How to insert images in Google Sheet cells [with built-in functions and Google Apps Script] – Digital Inspiration

Image credit: Amit Agarwal (@labnol)

Learn about the different approaches that will help insert images in Google Sheets and understand the reason why you may prefer one approach over the other.

In this tutorial Amit Agarwal covers the various ways you can insert images into Google Sheets, including with Google Apps Script. As part of this you can learn about the CellImage and CellImageBuilder which are relatively new features for adding an image to a Google Sheets cell. There are some useful code snippets included in the tutorial that can be dropped into your own projects.

Source: How to Insert Images in Google Sheet Cells – Digital Inspiration

Retrieving Google Docs summaries using Google Apps Script (hint: it’s using the existing Google Drive description property) 

This is a sample script for retrieving the summary of Google Document using Google Apps Script. Recently, a blog of Auto-generated Summaries in Google Docs has been posted. I thought that this is very interesting function. I thought that when this function is released, checking each summary of a lot of Google Document will be much useful for simply confirming the document content. And also, I thought that when all summaries can be retrieved using a script, it will be also useful. In this post, I would like to introduce to retrieve the summary of Google Document using Google Apps Script.

There are a couple of pieces of interesting information highlighted by this post by Kanshi Tanaike that caught my eye . First, useful to have a reminder that Google announced automatically generated summaries in Docs in February 2022. This might be a premium feature for the paid Workspace accounts as like Kanshi I’m not seeing this yet in my own free Google Workspace domain. The bit that really caught my eye is Google Docs summaries are using the existing Google Drive description property, which means it is not currently available via DocumentApp or if using the Google Docs API as an Advanced Service Docs. I’m sure this will catch some people out and hopefully this post will point people in the right direction.

Source: Retrieving Summary of Google Document using Google Apps Script

Unnest an object with array values using cartesian product [for Google Apps Script POST/GET web apps]

Convert array values from the doGet & doPost event parameters into 2D array when writing them onto a Google Sheet.

Sourabh Choraria has hit a rich patch of Google Apps Script exploration and following the post we shared recently on Google Sheets cell precedents in this latest post Sourabh looks at restructuring data into a cartesian product. The post contains some nice other ‘Easter Eggs’, in particular, worth checking out Sourabh’s latest Workspace Add-on, Webhooks for Sheets, and a snippet of code on GitHub used in the add-on for handling GET and POST requests.

Source: Unnest an object with array values using cartesian product

Getting started is the hardest part: Find inspiration with new Apps Script samples

Google Apps Script is a hosted JavaScript development environment that makes it easy for anyone to build custom business solutions across several Google products. Figuring out where to begin can be a hurdle for such an expansive tool, so we’ve recently released 10 new inspirational sample solutions to help you get started. These additions bolster the Apps Script documentation, which now hosts more than 30 sample solutions.

Here are a few use cases our newest sample solutions address:

Google recently announced latest figures around Google Workspace reach in 2021:

With 3B people globally using Google Workspace there is an opportunity to grow the Workspace developer community and to help users get started Google have recently published 10 new sample solutions. The samples cover a range of coding skills and even experts should take a look as there are some great examples that can help with developing add-ons, Google Chat apps and more.

Source: Getting started is the hardest part: Find inspiration with Apps Script samples

Announcing the Apps Script connector for AppSheet: Automate workflows for Google Workspace

This week, we launched the Apps Script connector for AppSheet, which now makes it possible to call Apps Script code functions from a no-code AppSheet app. This greatly extends the abilities of AppSheet apps by letting them access the power that Apps Script provides. For example, an AppSheet app can now use Apps Script to automate workflows with Google Workspace using the Workspace APIs for Drive, Docs, Sheets, and Admin SDK, and more – as well as other Google services like YouTube, Google Analytics, and BigQuery.

We’ve previously highlighted the Calling Google Apps Script from an automation in #AppSheet, which at the time of writing was a preview feature. This feature has now been announced as being generally available to AppSheet users.

If you are already familiar with this new feature you may find it useful to read the full announcement as it contextualises this feature within the ‘no-code’ / low-code marketplace and the benefits of integration with Google Workplace, Workplace APIs and other opportunities through Google Apps Script.

Source: Announcing the Apps Script connector for AppSheet: Automate workflows for Google Workspace