Complex Transfer of Data from Email Attachment to Template - arrays

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.

1) You can use a search query when retrieving the messages list [1][2].
2) You could develop your own code to get the messages list and get the attachments for each email using GmailApp class [3].
3, 4, 5) You'd first need to convert the excel to Google Sheets [4], to be able to manage the Spreadsheets easily with SpreadsheetApp class [5].
6) You can copy the Spreadsheet like this [6] and get the entire range of data to clear it [7].
7) Use this [8].
[1] https://developers.google.com/gmail/api/guides/filtering
[2] https://support.google.com/mail/answer/7190
[3] https://developers.google.com/apps-script/reference/gmail/gmail-app
[4] Converting .xls to google spreadsheet in google apps script
[5] https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app
[6] Google Apps Script, copy one spreadsheet to another spreadsheet with formatting
[7] https://developers.google.com/apps-script/reference/spreadsheet/range#clear()
[8] https://developers.google.com/apps-script/reference/drive/drive-app#removeFile(File)

Related

How can I check if strings match?

I have a Google Sheet document that I only have read access to.
It has a set of workers in it. One of the fields is for "job location", and another is for "house location". When these fields don't match, the worker is "remote".
I'm trying to add a calculated column to a data source in Google Data Studio, but I can't find any string function that checks for equivalence, and just going J=K doesn't work.
The CASE operator isn't able to compare columns either.
Is there a way to make a formula determine if two fields are equivalent?
For future reference, the feature was introduced in the 07 Jan 2021 update; thus using the fields specified in the question (job location and house location), the CASE statement below does the trick:
CASE
WHEN NOT job location = house location THEN "remote"
ELSE "not remote"
END
Editable Google Data Studio Report and a GIF to elaborate:
Currently, there is no direct solution in Data Studio to do this.
However, you can take one of two approaches:
Create a new Google Sheet. Use IMPORTRANGE to bring in entire dataset from the source Sheet and then add the comparison column in this worksheet. Use ARRAYFORMULA to extend the formula all the way to the end. (e.g. =ARRAYFORMULA(D:D=E:E) - can be further polished) This Sheet can then work as your data source.
Create a Community Connector to fetch data from the Sheet using the Sheets Service. Add the comparison as a column in Apps Script.

Complex linking in excel (dynamically?)

I'm not the best at using spreadsheets but I've given a task and its possible I may be a little out of my depth (I'm more of a web programmer)
I have two sheets:
One called Area A and one called Area B with headings:
Time - Location - Reference
I need to set up a new sheet with these column headings:
Time - Reference - Location - Area
Then make a sortable list (I can do this bit)
The Location A & B sheets will be constantly changing and this will need to be reflected in the new sheet when ever it is opened (maybe some sort of onload style event?)
Any ideas on the easiest way to do the above (or if indeed it is doable)? I don't want to be spoon fed, I'd be happy to be pointed in the right direction or to be given some keywords I can Google (I learn better this way).
Many thanks!
This type of data manipulation is something that excel is not good for and is prone to errors.
The best two good ways to do this.
Manually
On sheet "Area A" add a column with area name I.e. Area A. Do this for each "data" sheet. Then manually or via vba copy and paste one sheet at a time to you're aggregated sheet.
Programmatically using VBA
Loop through each sheet and copy and paste to the aggregated sheet adding a column with the sheet name as you paste.
For either of these methods the important thing to do is build in a few checks on counts at the end to make sure your not missing any data.

Running Database in Excel

Is there a way to create a running database in excel (and only in excel, without using third party programs) so for example:
-One worksheet has today's data for each person
-The additional worksheets (one per each person on the first worksheet) keeps a list of each of the past columns
-Each of the worksheets, except for the current worksheet, charts each new row of data added daily.
Here is a picture in case it helps:
This can be done in Excel, but you need to get the data architecture right.
Use ONE sheet for all raw data. Columns are Date, member, score, number of pages, number of files, notes. New data goes at the bottom of the list. You can use VBA to create a data entry form if you don't want to enter data straight into the sheet. The sheet can be hidden, if needed.
Then use ONE other sheet to create a dynamic report where you can select the time frame and the member to report on. Data is pulled from the raw data sheet and aggregated as required. Pivot tables are immensely powerful.
Using a sheet for each member would be duplication of functionality and bad data design.
Edit: a few conceptual screenshots
The raw data table. New data is added at the bottom of the table. A VBA form can ensure a pleasant user interface, so that the user never sees this table.
The report could be a pivot table grouped by date. Slicers allow the selection of specific time frames, for example a month. Another slicer allows filtering by a specific member.
It took me roughly 5 minutes to create the scenario, including making up the dummy data. With a few hours to spend, this could be made really shiny.

Tie stock quote value to cell in Excel 2011 Mac

I've been working on a mock stock portfolio in Excel, and I've been looking for ways to automatically update the data, eg. stock price and P/E ratio.
I have tried using a web query to MSN Money, but that just brings up the whole stock quote across multiple cells, I want data to be updated in individual cells only. The only web query solution I can think of is if someone hosted a website where each value in the stock quote was saved on a different HTML file. I could then WebQuery to that file for each cell requiring that value. However, no website offers this.
So in essence, is there any tool on Excel 2011 Mac that will let me pull individual values from a stock quote and assign them to a single cell?
You could consider the following:
For each stock, create a worksheet which contains a web query to that stock's web page.
Next, create a summary sheet, from where you link to the cells on the individual stock worksheets which contain the data you need.
Then, with 'refresh all connections' your data on the summary worksheet would update.

Generate multiple Visio files from a database

I have an Access database containing information about multiple clients.
I can put these datas into one table (1 row = 1 client).
I want to create vsd files from this table. I want to draw a Template and associate forms with fields.
I'm new in Visio, but I succeed in mapping a table to a draw, but I don't know how to ask Visio to generate a file per row. I'll appreciate any help.
I don't think it's possible, so I wrote a PowerShell script to do the job.
For each row, it open and edit the Template and save it Under a new name.

Resources