hello everyone,
I am getting the data into an excel file , afterwards with the if condition I am saving this data to to 2 different datatables. now I want to get a count of these records from these 2 tables and display the count along with some text into excel file.
I used readcsv activity for reading from csv file and with for each row activity m going through the table checking for specific condition and saving data to 2 different tables . Now I want count of both these tables so hoe can I get it, which activity to use ???
For getting the count of the datatable you can use : DataTable.Rows.Count
Hi rashmi,
thanks for the reply…
also I want to search for a specific keyword in datatable rows for that m using ,
for each row…
for each item in datatable… and below this in if condition m checking items like InputDataTable.Rows.Contains(“MM”)
but this is giving me error as rows.contains gets input of a key
can u please tell me how can this be achieved.
@Sheetal6289 pease try something like…
dt.Rows(rowidx).Item(“ColumnName”).ToString.Contains(“Keyword”)
Regards
Madhura
hey madhura,
thank for d reply.
m new to this .
can u please tell what will b my rowindex and also column name ?
my data is in “C” column. and I have to iterate through all the rows to check for the data.
Row Index is your row number inside datatable, which starts with 0
Column Name is the column header you have given in your excel file.
If you check AddHeaders property while reading excel sheet, then column names will be which you have mentioned in first row in excel sheet, otherwise they will be column0, column1 and so on…
Instead you can mention column index which also start from 0. In you case the data is in C column, so the column index will be 2
Instead you can use
Put your column Name instead Status
Regards
Madhura
thank u so much for ur reply madhura…
it worked n I got the result , was trying from past 8 days.
thanks a lot…
hi -
use below to get row count on data table.
“table_name”.Rows.Count()
Hi madhuraj, i have a quite similar case where I have values in a data table with 15 columns , but I need to check the values only for 2 columns. In that 2 columns also I need to check if the cells if it is nothing then it should check for the next . so for example if the values would have been in the second row then the first row would have been null so it should go to the next and if it founds the values then get the values
need assistance on this
Hey,
Here is an detailed article on it
# How To Count Rows In DataTable – In UiPath
Regards,
I think the problem is the how DT store the values. It is the reference type.
For example , If u declare DT A and B, assign like A=B
whenever you update the data in DT A, B will be automatically updated since it is the reference type.
So make sure to get what you want , when you declare the two DTs, please declare B= A.copy
So A and B will not be same anymore if you make changes to any of them.
Hope it helps.
Many thanks, I wanted to make a condition based in the rows of a datatable over 0, and your hint helped me.
DataTable.Rows.Count>0
Simple, but without the start…
@Sheetal6289 Hi I am curious to know if you were able to fix this? Since I have similar example. Thanks.
Hi @Alvin,
Also we can do this with the help of Filter Datatable activity. We can pass A as input and B as output datatable but without any filter conditions. It seems more understandable to others.
Hi @Rashmi
I want to count each row step by step and i want to see which rows i am in.
What is the suitable code for that ???
@170290064
I suggest to you
you need to take read range activity and after that take For each row in data table activity
take assign activity and
Var=“your column name”
now you can be see one by one row data
Regards
Zaid Qazi