Hi all,
I am trying to get the text from these the headers of a datatable and click the button depending on if the text contains Thu for example.
How do i loop through and get the text for example ‘Thu’, ‘Fri’ from this datatable.
When i run my for each loop i just get ‘Column-1’, ‘Column-2’ etc.
Here is an example of my sequence.
1 Like
aquinn
(Aquinn)
November 16, 2022, 11:23am
2
use the for each with your datatable and in your case to get the output you would use
col(“Column-0”).tostring or whichever col you are using to get the value.
e.g. if my data table was called DT_Col and i was using for each col, i would write in an assign or message box
Col(“Column-0”). to string OR VAR_COL = Col(“Column-0”).tostring
1 Like
aquinn:
(“Column-0”)
Hi aquinn,
Thanks for the responce. Still getting this error though.
1 Like
aquinn
(Aquinn)
November 16, 2022, 12:45pm
4
please follow this screenshot, use a for each row in data table
1 Like
Hi aquinn,
Again thanks for the help but i need to get the text from the columns.
I need to be getting 18/11, 19/11 etc.
So instead of iterating from top to bottom i need to be going from left to right.
See screenshots attached.
1 Like
Hey @Alexander_Ward
You are getting datatable as a output from Extract Table Data, So use the same variable and loop it through the regular for loop.
<Your_DataTableVariable>.Columns ( Place this in the condition of the for loop)
You will be getting column headers in each iteration, further you can put your conditions.
Regards.
1 Like
aquinn
(Aquinn)
November 16, 2022, 1:31pm
7
Instead of using col(“column-0”).tostring you can use column(1).tostring for the next column along which would be the date, then (2) for the 3rd column etc
1 Like
Hi @Alexander_Ward check this screenshot
It will return the columns
1 Like
ppr
(Peter)
November 16, 2022, 1:37pm
9
the foreach typeargument is to set to DataColumn
when retrieving the columnname is needed we use
col.ColumnName
1 Like
I would have to do a multiple assign with that wouldn’t i?
Because there is no way increment that column-1, 2, 3 etc as im doing a for each row?
Thanks
1 Like
ppr
(Peter)
November 16, 2022, 1:55pm
11
maybe reread above.
do a first start with:
For each Activity | TypeArgument: DataColumn - col in YourDataTableVar.Columns
log message: col.ColumnName
1 Like
ppr:
col.ColumnName
Hi Peter,
Thanks a lot for that it seems like it’s working correctly. The only thing is i need to be reading the text for the 2nd row only. As you can see in the screenshot i just want the dates.
Is there anyway you can do this but for the 2nd row?
1 Like
ppr
(Peter)
November 16, 2022, 2:23pm
13
For each activity | item in YourDataTableVar.Rows(0).ItemArray - typeArgument: Object
log message: item.ToString()
1 Like
Hi Peter,
Thank you so much that seems to be working! Really appreciate it
Can I just ask one last thing regarding the output is there anyway i can possibly skip the first 2 columns?
1 Like
ppr
(Peter)
November 16, 2022, 2:30pm
15
YourDataTableVar.Rows(0).ItemArray.Skip(2)
1 Like
Seems to be getting an error on protection level. See attached screenshot.
Thanks
1 Like
ppr
(Peter)
November 16, 2022, 2:36pm
17
was a typo use dot instead of comma. check updated statement
1 Like
Thanks a lot Peter.
Really appreciate the help.
Have a good rest of your day
Thanks
1 Like
ppr
(Peter)
November 16, 2022, 2:47pm
19