How to check the data inside CSV file is empty or not

I have one strange case in which if user submit data as empty so uipath cannot find any row in CSV file and also cannot confirm that CSV is empty or not.
Please help me on this that how to confirm CSV is empty or not.
I am attaching both the files(I convert to .xlsx because cannot upload CSV)

Buddy @zeshanm9

You can check whether a csv has any record or not by using these steps

  1. Read CSV file activity to open the csv files and get the output as datatable named out_dt and enable this property buddy to take the first row as header
    image
  2. and using assign activity to get the count of records in that datatable
    like this
    out_row_count = out_dt.Rows.count

this would give us the count of records and using a if condition like
out_row_count>1
and if this condition gets passed you can continue with the activities you want in THEN part of if condition or you can do the alternative in ELSE part of if condition
buddy @zeshanm9
Try this and let know whether this works with your scenario or not
Cheers buddy

Yes @Palaniyappan i try the same but not working as there is headers only in the file so it will always show there is data in the file but in real there will be no data except the ColumnNames only.

out_row_count>1

Thats why i mentioned like more than 1 buddy
and i think that should work buddy

buddy @zeshanm9

pls wait one min

yah here you go @zeshanm9
try this buddy lets see i hope it should work
CSVEmptyorNot_modified.zip (12.7 KB)

Cheers

1 Like

Did that work buddy
@zeshanm9

Yes thank you @Palaniyappan its working :slight_smile:

Hi @Palaniyappan i try the solution in my real code but its not working

when i try to run it in separate flow it is working but not working in my main process

1 Like

Buddy may i know what was the error in that buddy @zeshanm9
Cheers

eeeeeeeeeeee
this error when csv is not empty

Kindly check you have the column named with Parcel in your datatableand make sure if any read range activity is used check with Add headers property is enabled or not buddy @zeshanm9
Thats the reason behind buddy for this error

yes i check ad headers is disabled but when we enabled then the row counter does not work

1 Like

Try this buddy
@zeshanm9
DAte.zip (12.3 KB)

Did that work buddy @zeshanm9

Yes @Palaniyappan Great that’s working now.

1 Like

Cheers buddy @zeshanm9
keep going

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.