How to UpSert on Google Sheet with unknown columns

Hello,

I am trying to build a system that downloads an Excell that has the unknown number of columns with unknown names. (One set of columns for each download).

I have a Google Sheet that has those exact “unknown” columns in it, and I want to use UpSert to insert only new columns, and only update the existing ones. The issue.

I always know that the Sheet will have one specific identifying column that can be used to differentiate between rows.

When I select it and run it, I always get the error:


When I use Insert, it works fine.

I am just trying to figure out how to insert only new columns, so maybe one way can be checking for each row does it already exist, if not, then insert, but I am not sure about speed, because I am dealing with 500+ rows with multiple projects sequentially.

Does anybody know of a solution?