-2

I am trying to use Google Apps Script to take a CSV of my aviation logbook and populate a template, 16 lines at a time, until reaching the end of my entries. The logbook exists in a Google Sheets file right now, as does the template.

My question is: -Is it okay to have my template already across two individual sheets and achieve these results?

My vision for the process is:

  1. Export sheets file to CSV (no headers for match reference, but columns will never change order to accommodate indexing).

  2. Take data from CSV in 16-line chunks and plug into template. (while loop?) (Template has two sheets for left and right sides of a logbook)

  3. Populate bottom three rows with sum of relevant column of current chunk of 16 lines (1), sum of relevant column prior to line 1 of current 16 line chunk if it exists (2), and sum of relevant column From beginning of data to end of current 16 line chunk (3).

  4. Save each completed template as a new sheet or file to eventually be strung together.

  5. Repeat the process until reaching the end of the entries contained in CSV.

  6. Compile all of the "pages", alternating left and right, and save as PDF.

The template has two sheets inside to mimmic the left and right side of an open book and make the final format easily printable. I would like to achieve all of this with Google Apps Script to avoid having to download/upload files and do it through a third party.

Template- https://docs.google.com/spreadsheets/d/1CWVaFWFJJdaEk9mvHy2yuh_ACSsuIG9u6faggEwNzVc/edit?usp=sharing

Source Data- https://docs.google.com/spreadsheets/d/1ktPW89As37cvZLZfhCWIc64hQ-mJTIgjWWjQgMvx9z8/export?format=csv&gid=1216687950&range=A4:BH

  • 3
    Welcome to [so]. What is the question? (questions on this site should be specific, ref. [ask]). – Rubén Sep 14 '20 at 02:10

1 Answers1

2

You can make a template spreadsheet first and reference it in your script.

You're going to need a script to parse your csv. Then in that while loop that parses the csv the script will make copies of the template and copy in data in 16 line chunks into these copies.

Or in the loop you could make copies of the template and copy them into a single spreadsheet as workbooks (tabs) then export the whole sheet as pdf.

For the sums you can put a formula in the template

Possible other solutions: Is it possible to create a single pdf from multiple Google spreadsheets?

Howard Luong
  • 36
  • 1
  • 2