Copying a value from colum 1 when specific date value is found in column 2 for each row


#1

Hi!

I am building a robot that needs to scrape data from a webpage (it will be a table) and that table has two columns (called POnumber and POdate).

I want the robot to read each row, reading the POdate and if that POdate is yesterday, then copy the POnumber from that same row. For example:

(this is a copy from the notepad, where I printed my table just to see the two columns)

POnumber,POdate
1760 ,03/28/18
4701 ,03/27/18
1630 ,03/27/18
1619 ,03/26/18
1575 ,03/25/18

So, for this table, I want to read the first row, and ok, that is not yesterday, so nothing. The second row has yesterday’s date, so I want to copy the number 4701 from that same row. How could I do this, I have no idea?

After copying the number 4701, I want to find that number on a webpage and click on it, so I guess I need to save that number to a variable also?

Here is what I have come up with so far, but it is missing a lot (I am also not sure if the date will be in the right format if I use the code I currently have there):


#2

(And yeah, I already have the table ready, so this is just for the comparison, copying the value, finding it on a webpage and clicking on it parts)


#3

Hi @JohannaKes,

use if condition dt.select("POdate='03/28/18'").length>0

True ->
DateTime datevalue=Convert.ToDateTime(dt.select("POdate='03/28/18'")(0)("Ponumber"))

Regards,
Arivu


#4

@JohannaKes
First get the list of PONumbers whose date is Yesterday.

ListA=(From p In Dt.Select
where DateTime.Now.AddDays(-1).ToString(MM/dd/yy).Equals(Convert.ToString(p.Item("POdate")))
Select Convert.ToString(p.Item("POnumber"))).ToList

Now the List A will contain only the yesterday POnumbers.

Now run foreach for ListA and Click on the elements if it founds.

Regards,
Mahesh


#5

Thank you everyone for your answers! They were helpful and we managed to use them in the solution.