Hi,
I have an Import CSV server action which I need to check if its empty.
How do I return an error if the file only contains headers and no row data?
I tried the following, and
Thanks,
Ray.
Hi,
I have an Import CSV server action which I need to check if its empty.
How do I return an error if the file only contains headers and no row data?
I tried the following, and
Thanks,
Ray.
I wouldnât have thought it would be possible to determine if a single row of data is a header or actual data. If you know the file will contain a header, you could test for a single row being imported.
Hi @TomD,
The you can tell the Import that your file contains headers, so I would have thought I could check for rows.
Ray
Why not use your database query for results?
If it returns > 0 records then do the export.
Hi @Teodor,
This is an âImport CSV fileâ action I am performing.
I need to ensure the user has not just uploaded a file only containing the header, and if they did, I will return an error onscreen.
It would be great if we could do some validation on the âImport CSV fileâ out of the box.
But on import headers are not considered a recordâŚ
You can set a condition which checks if the imported file returns has records or not:
Thanks @Teodor. I was trying to check for null, but now I can see that a zero count would have worked for me.
Hi @Teodor is it also possible to check for duplicate values on the Import?
e.g. Check if a column on the CSV file contains the same value twice and if it does return a response?
I need to raise an error if the Column A(Proxy) value has been entered twice. I need to do this before I commit to the database.
You can check the value using a database query - use the csv column as a query filter.
Add a condition which checks if the database query returns a record and add your steps there.
Hi Teodor, I need to preform the check on the import file to ensure that it does not have it duplicated. In the previous post you will see Row 2 and 3 have the same value under column 1.
What I donât want to do is import the data into the database if the value exists more than once in the file.
If it needs to be done a DB level, that wonât catch if the value has been duplicated in the file, it will only tell me if already exists on the DB?
Yes, but if it doesn't exist in the db, and it exists twice in your CSV, then it will be added the first time when you do the insert, then it won't be added the second time as it already exists ...
I understand what your saying, however, then I wonât be able to warn the user that they have entered the value more then once and I could have committed most of the file to the DB?
So whatâs your idea exactly?
Isnât it - not to enter duplicate records in the database? Or is it something else?
I want the user to be warned that they have added a duplicated value, which could have been a simply typo on their part, and that they need to correct the file and re-upload after fixing the file by either fixing the value or removing the line completely.
If I go by the example below.
Ray and James are both to receive a value, but the user added the same Proxy to both users. If I simply removed the duplicate, then James will not receive a value at all.
By highlighting to the user that they have duplicated the Proxy value, they can amend the Proxy to the correct value and then resubmit.
And do you want to check this for a specific column? Or all columns?
Just a specific column.
Well in this case you can check if the number of unique records are equal to the number of total records
you can build pretty much everything you need to check/compare using the data formatter.
Didnât catch the duplicate?
Now, I did type in Proxy into the Property Field.
If I try using the picker I get the following, which also does not catch the duplicate, but Iâm sure thats because itâs only getting the first row [0]
How about having a separate table called âduplicatesâ and insert records in there if they appear more than once? Then you can report back exactly which records were duplicates.
Your condition is wrong on your screenshotâŚ
If unique items count == total items count, then there are no duplicates
You need to put the response in the other step (else).