Importing CSV into Retool Database Table with null values

Hey folks! Sorry for initially underestimating the impact here and thanks for following up on the thread. I've bumped the issue with the dev team and can let you know here when it's fixed.

In the meantime, you might try manually importing the data as @sr112233 mentioned. It is possible to do this with Retool as well! File input components have a Parse files setting that will automatically read CSV files:

With the setting turned on, any uploaded CSV should be accessible in JSON form:

As such, empty fields will still be represented as empty strings, but you can map over the result to convert them to null values with something like

{{fileInput.parsedValue[0].map(row => _.mapValues(row, (value) => value === "" ? null : value))}}

(More docs on _.mapValues here!) You can then use that result in an upsert query to your Retool Database resource:

Can you let me know if that works for now?

1 Like