I have a complicated project I am undertaking for my work, and any advice you could give would be really appreciated.
Basically here is what I want to do:
- Filter Emails from specific people
- Download those emails' attachments (they are excel format) to a specific folder in Drive (called "Input")
- Pull the data from those spreadsheets to specific cells of another spreadsheet (master template) I have in another part of Drive (probably over a hundred cell value transfers)
- Automatically delete the downloaded attachments in the drive to prepare for the next (same name) files that will be downloaded tomorrow.
- Once the master is filled up, make a copy of the entire spreadsheet, rename it to today's date, and then wipe the master to rinse and repeat the same process tomorrow.
So right now I am just working with this conceptually, here is a basic blueprint of what I am thinking about doing but your input would be much appreciated:
Filter emails using Gmail's Label system
Use this method to download emails: https://www.splitbrain.org/blog/2017-01/30-save_gmail_attachments_to_google_drive
Create a permanent spreadsheet in the "Input" folder (called "Master Array") to array all the data from the downloaded spreadsheets and their respective sub-sheets. The goal here being to have one constant File_ID housing all the data.
Create a search if array function in the Master Array which will search for the correct files by their respective name and array their data in the correct subsheets in the Master Array spreadsheet (i.e. If file name contains "Company Sales" array data in "Sales" subsheet).
ImportRange, Query, Vlookup, etc. that "Master Array" spreadsheet and pull all the values I need out of there to the respective cells in the Master Template they need to be.
Once the Master Template is built, I want to copy the entire spreadsheet, rename it to today's date, and then wipe the original (preparing it for the same function tomorrow). (using google timer trigger)
Delete all the downloaded email attachments in the drive folder "Input" to rinse and repeat for the same function the next day. (using google timer trigger).
Some questions I have:
Is there a more efficient way to do this?
What is the best way to copy data from one spreadsheet to another, would it be quicker in script, or as a import function within each individual cell of the master template?
Can I use a loop/if function to pull certain cells to certain sheets within the Master Template, basically having functions for each sheet name, so say IF sheetname="Sales" pull cells A2 from the other spreadsheet to b3... etc.
Sorry this is very long and robust, just wanted to see if this is possible to do comprehensively or not. Thank you for any and all input, I am relatively new to Sheets so forgive my naivety.