I have a dataset with 3 columns. The data contains car data and I want to use a google apps script to split the dataset by car manufacturer into several datasets. Each subset would then need to be pasted into a separate worksheet within the google sheets script. I'm having trouble with dynamically getting the car manufacturer subset. Is there an effective way to get the subset and copy over to separate datasets? The other challenge is that the car manufacturer names have numbers tacked on at the end that vary in length. I would want all of the instances to be copy pasted into the right car manufacturer worksheet, so is there a way to identify the car manufacturer in the id and paste all the necessary rows? Also, is there a way to take the car manufacturer name and use that to rename the worksheet name when copying over the dataset?
Below is an example of what I'm hoping to do. My dataset looks like this in my worksheet:
| Manufacturer | Year | Purchase Timestamp |
|---|---|---|
| Ford250 | 2018 | 5/19/2022 13:10:25 |
| Ford4560 | 2019 | 6/03/2022 13:10:25 |
| Ford12389 | 2020 | 8/22/2022 13:10:25 |
| Toyota1 | 2011 | 9/07/2022 13:10:25 |
| Tesla45678 | 2009 | 7/03/2022 13:10:25 |
| Toyota89 | 2009 | 3/15/2022 13:10:25 |
In the above sample google sheets dataset, I'm hoping to get 3 subset datasets split by manufacturer (Ford, Toyota, Tesla) that would then be saved in separate worksheets within the Google sheets file:
Subset Dataset 1 (Ford):
| Manufacturer | Year | Purchase Timestamp |
|---|---|---|
| Ford250 | 2018 | 5/19/2022 13:10:25 |
| Ford4560 | 2019 | 6/03/2022 13:10:25 |
| Ford12389 | 2020 | 8/22/2022 13:10:25 |
Subset Dataset 2 (Toyota):
| Manufacturer | Year | Purchase Timestamp |
|---|---|---|
| Toyota1 | 2011 | 9/07/2022 13:10:25 |
| Toyota89 | 2009 | 3/15/2022 13:10:25 |
Subset Dataset 3 (Tesla):
| Manufacturer | Year | Purchase Timestamp |
|---|---|---|
| Tesla45678 | 2009 | 7/03/2022 13:10:25 |
Additionally, I'm trying to perform automation using google apps script, so I want to avoid making a column manually and use something like regex.