Skip to main content
June 20, 2025
Question

Does Import CSV to Database v6 work for csv file with null values?

  • June 20, 2025
  • 12 replies
  • 0 views

I have a csv file with delimiter '|'. When I try to run the smart service by passing a csv file where few fields are null, it is returning the error message 'Error executing SQL'. But when I replace the null with random text values it is writing the data to DB.

Is this an expected behavior of this smart service?

Is there any way to import or read a csv file with null values?

12 replies

June 20, 2025

Are the null values separated by your defined delimiter?

June 23, 2025

Yes, the null values are separated by the delimiter

srmm0001
June 22, 2025

Hi, 

Yes, it works with nulls only if the database columns allow null values. If columns are NOT NULL, it fails with "Error executing SQL." Update DB schema or preprocess the CSV to fix it.

albertoc033829
June 23, 2025

The best approach is definitely to verify the database schema, as Srinivas mentioned. If the columns are defined as NOT NULL, then inserting null or empty values will cause SQL errors — which seems to be exactly what's happening in your case.

If modifying the database to allow nulls is not an option, there is a workaround:

You can use the readcsvlog() function to read the CSV file into a CDT. Once the data is loaded, you can loop through the CDT in Appian, check for null or empty values, and replace them with default values (e.g., "N/A" for text, 0 for numbers). After that, you can insert the cleaned data into the database using Write to Data Store Entity.

However, this workaround is significantly more complex and less efficient than simply updating the database schema to allow nulls in the appropriate columns. If possible, adjusting the DB structure is the cleaner and more maintainable solution

June 23, 2025

readcsvlog() function only allows to read from log files. We won't be able to read from csv document.

albertoc033829
June 23, 2025

You're absolutely right — I responded too quickly without thinking it through.

The readcsvlog() function is specifically designed to read log files, not general CSV documents. It only works with the application server log files, not with user-uploaded CSV files stored as Appian documents.

Thanks for pointing that out! I appreciate the clarification.

June 23, 2025

But I noticed today that if the 1st column in the CSV file is empty then it is throwing this error, if other columns in between are null, it is able to read and write NULL to the DB.

albertoc033829
June 23, 2025

I just tested this on my side and it works correctly even when the first column is empty — the data is read and inserted as null into the database without any errors.

Are you sure the column mapping is correct in your configuration? It might be worth double-checking that columns in your CSV matches the expected structure and that the target table and allows nulls where needed.

Would you mind sharing a sample of the CSV file that’s causing the issue, along with the table script you're using?

That would help a lot to reproduce the problem and see what might be going wrong with the first column specifically.

Thanks!

June 23, 2025

Realized I'm using an old version of the plugin, I will update to the latest version of the plugin and give it a try.