Sort a Data Scraped Result According to a condition

IMG_22122017_172341_0

Hi @amithvs,

When u already have a datatable lets say DT1.

Then use For Each Row activity and iterate thru datatable DT1.

Then under its Body Section of this activity , use Get Row Item activity and specify the column name / column index of Hotel Name , in the properties pane of "get Row item " activity.

If the Hotel Name is the 2nd column - then just mention Column Index as 1.

Store the o/p of "get row item " activity in variable called as Var1.

Now use msg box and type var1.tostring

It will display all the Hotel Names for each row.

Now use a simple If condition to check if the Hotel Name contain letter A or not.

***************************************** IF PART ********************************
SCENARIO : HOTEL NAME STARTS WITH ‘A’

Then use another get row item activity and specify the column index of the Fare column.

Lets say the Fare col is the first col then specify the col index as 0.

Now store the output of this “get row item” in var2 .

Now use the msg box and type in var2.tostring

Var2 will display the corresponding Fare.


***************************************** else PART ********************************

SCENARIO : HOTE NAME DOES NOT START WITH A

then leave that else part as it is .

dont add any activity in it .

***************************************** else PART ********************************

u will see that only when the hotel name starts with A , you will get a msg box which displays correspoding
fare.

or else it skips that hotel and goes to next one.

Hope that clears ur doubt :slight_smile:

Cheers mate

2 Likes

Tanx a lot mate. Will check this method keep u updated… merry xmaz and newyear in advance

1 Like

Cheers Mate :slight_smile:

I wish you the same :slight_smile:

1 Like

hey @prassin6, it worked perfectly , tanx a lot. But the output list is in gneric type. I need it as array of data row. I tried changing variable type for var2. but not working.Any tips for that?

Hi @amithvs,

I did not understand this part - Could you please elaborate :slight_smile:

If you want to store the fares as an array -

Under the SCENARIO : HOTEL NAME STARTS WITH 'A’

You will find all the Hotels which start with A and thier Fare is stored in var2

So if u want to store the Fare in array of String.

Then do one thing:

Create an array and keep assigning the Content of var2 in that array

actually I want to invoke this workflow somewhere else. The input allowed in the new workflow is of type array of datarow (the input is var2). As var2 is of generic type im bit stuck

hi @amithvs,

I am actually busy with my own projects.
But anyways , I wud like to make an attempt.

Is it really necesary that it needs to be sent as an array only to input of new workflow. ?

Is there a possibilty of manipulating the Second Workflow so that It takes Generic / String Type data from original workflow.
Please share ur .xaml file.

Just to confirm again, all the contents of Var2 shud go to an array Variable , i.e array of strings .

Is that right ?

all the contents of var2 should go to an array of datarow.

Please advise on this

hey, I have to iterate through the var2 using Foreach item. I tried changing the typeargument of for loop to generic. but ending up with error. So I guess there is no hope to manipulate the new workflow to generic.

Also please don’t get me wrong, I cannot share the xaml bcoz it is part of my project. PLease update me if there is any info from ur side. :slight_smile:

Hi @amithvs,

If you want to iterate through Var2 using For Each Item :slight_smile:
Then store the contents of Var2 to dynamic array of String.
And then Iterate through it.

If you want to iterate through Var2 using For Each ROW :slight_smile:
Then keep writing the Var2 into an excel file.
Later use read range and read the column which contains all the Var2 Contents and Store it in Datatable - DT1
Then use For Each Row and iterate through the DT1.

Please try this , as this is what I can suggest.

Var2 cannot be directly written to an excel file. I used generate datatable within excel scope and gave the output (lets say ‘generate’ of type datatable) to write range. But the output that I am getting is only the last value of Var2 in cell A1. When I run the workflow i can see the rest of the data from var2 populating the cell A1. so when workflow is executed only data I can see is the last written data.

Despite of this I invoked it to another workflow, assigned generate to a a new variable var3 of datatable type.

For each row var3,

But I am getting error as below, I think it is due to the output from the generate datatable bcoz it contains only one data so no way to iterate

.Untitled1

Well good u tried this , Now instead of write range , use append range and specify “A1”
Coz this is where u want to start appending the data.

So 1st data will be written in cell A1, then next one in A2 like that it will go on filling A column …:slight_smile:

Once all the the var2 data is written one below the other in an Excel File.

Use read range to read all the Data of Var2 → Store Output in - Var3 DataTable , and iterate thru it using FOR EACH ROW activity as it is a DATATABLE.

But in Append range activity there is no option to specify the cell range. :slight_smile:

Dont worry Append Range By default manages the Data.

If there is one column of Data it starts with A1.

If there are 2 col(s) of data , it starts with 1st col of Data in A1 A2 A3 A4…
and second col Data in B1, B2, B3 …

I have used this append range Bro in one of my projects :slight_smile: and works :100:

All the new data keeps getting stacked one below the other.

1 Like

It worked bro!, Thank you

1 Like