Google Apps Script: Extract Specific Data From a PDF and insert it into a Google Sheet

Google Apps Script: DriveApp, Advanced Drive Service, SpreadsheetApp,  DocumentApp Javascript: spread operator, map, regex

Ah, bureaucracy at its finest.  Have you ever asked for a list from a client, another department or agency and instead of saving into a file that might even be considered marginally useful, they give it to you as a pdf. A… p…d…f.

Gee, thanks.

After some prostrations to the great Google Apps Script gods, I had a though.

“Hey, can’t we convert a PDF to a Google Doc with just a click of the button? Surely the great Google Apps Script devs have made it so we can do it programmatically too.”

And you know what? They bloody well did. The big legends.

The Scenario

I’ve just received a bunch of PDFs. The PFDs are all labelled by the class number. Take a look at the files in my Google Drive:

PDFs of sections in Google Drive

Each PDF file contains a list of student IDs that I need to extract and put into a Google Sheet.

PDF file with student IDs

The aim is to have a list of student IDs in column A and their corresponding sections in column B.

As you can see, we have some pretty standard text in the PDF that should be easy for Google to recognise so that we can extract the IDs.

The list of names in the demo sheets were randomly generated by AI!

NOTE! As always, I have tried to create this tutorial for varying levels. Feel free to follow along, or just grab what you need and get stuck into your own project.

If you are playing along, you can find a copy of the PDF files below. Simply add them to your own Drive before you get started:

PDF files by Section.

Continue reading “Google Apps Script: Extract Specific Data From a PDF and insert it into a Google Sheet”

Google Apps Script: Upload grades into a Google Classroom Coursework Assignment

Google Classroom, Google Sheets, Google Apps Script: Classroom API, SpreadsheetApp, map, forEach

At the date of writing this the world is in the midst of a worldwide pandemic – the Corona Virus.

For educators and their Igors administrators like me, it has been an incredibly busy couple of months.

Many of us have quickly sort to use online resources and tools to keep in contact with our students and take a crash course into the world of online teaching.

Google Classroom has become one of the darlings of the teaching world that has come out of this crisis. Its shallow learning curve and attractive UI made it an obvious choice for most educators. Oh, and I am sure the fact that it is free helped too.

For all of Google Classroom’s ease of use, I still feel the application is in its fledgling stages and does have a few limitations that, I’m sure, Google is constantly working on and improving.

One of the limitations is that you cannot simply upload grades from, say Google Sheets or another assessment tool. Well…not directly in the Google Classroom platform, yet.

However, you can still upload grades from an external source using Google Apps Script. You could use GAS to upload a whole courses grades from a Google Sheet. You could even use GAS to upload grades on a trigger from another assessment’s API into your Google Classroom.

In this tutorial, I am going to run you through the basics of uploading grades into Google Classroom using Google Apps Script with the Classroom API.

NOTE! This tutorial is for a wide audience. Feel free to read the post all the way through, or take what you need and get cracking!

Continue reading “Google Apps Script: Upload grades into a Google Classroom Coursework Assignment”