Recommendations on scripting for validating CSV import

I am working on an import view that will allow the upload of a CSV file to a table. The goal is to validate several fields that they are present, and a valid value. Especially converting lookups from name to ID in referenced tables.

I thought about adding the validation logic behind the Click event of a button but it seemed to be a large amount of code for an event handler. Can I upload script as a file and reference within the event handler? Sorry for the rookie questions but it's all new to me.

The upload will have dozens of columns and will need to process several 1000 rows when ran.

Thanks,
Kevin Brown

as long as validation logic is valid (you can't set variables, component values, or trigger a query) you could use a transformer

as a side note (incase you didn't know), queries and i think worflows have a max run time. depending on your code, I'd doubt 1000 rows w 20-30 columns would hit that max, if you find yourself in this situation I'd suggest using a custom component to do your processing, you should also notice a speed increase as a bunch of Retool overhead is more or less skipped

you could set an input for it as the csv location, then you can either update an input w an array of objects describing anything invalid (u use an input var as the output so other components have access to results posted by the custom component). from there you could filter out anything invalid b4 sending it to a table. here @Tess suggests passing in query1 as an input, then after your custom component finishes processing you update the model, then trigger query1 which triggers query2 w additionalScope values grabbed from the model. if you set query1 to trigger on input change, you'll enter an infinite loop, which is why we manually trigger query1 from inside the custom component.