Read the last row of a CSV


I am currently developing a process that requires the last data row of a spreadsheet to be read, and compare the identifier of another row in another spreadsheet to this last row. Once it has compared these and found a match, it adds a datarow to a datatable.


Currently, I am opening the spreadsheet, then using ctrl + end to get to the bottom of the spreadsheet, shift + space to highlight the row, and ctrl + c to copy the row. This isn’t working 100% of the time.

Are there any other ways I get the last row? Any help is appreciated.

Thanks in advance

hey @william.coulson,
1- read the entire sheet using Read Range activity
2- count the number of rows ( dtcount= dt,rows.count)
3- then use the read row activity and pass the dtcount variable in the range column (eg- “A”+dtcount)
I think it should work.


1 Like

ReadLastRowCsv.xaml (5.9 KB)

kindly try this…! @william.coulson


1 Like

hope these steps would help you on this
–use READ CSV FILE activity and pass the file path of csv as input and get the output with a variable of type datatable named dt
–now use a ASSIGN ACTIVITY like this
str_lastrow = String.Join(" ",dt.Rows(dt.Rows.Count-1).ItemArray).ToString

now this variable will have value of each column in last row with a space between each value

Cheers @william.coulson


@suruchi120294 @kadiravan_kalidoss @Palaniyappan,

All your solutions worked! I have marked @Palaniyappan’s solution as the answer as it is the first one I tried. Thank you all for your help! :smile:


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