How to sort the output of the data scraping

Hello guys,

I used data scraping to scrap the data from web which contains four columns. I have stored the data in a variable which is of type datatable. All I want is to sort the output and get the details of a single column.testupload.xlsx (9.6 KB)

Here I have to extract data according to following conditions:

item : levis
business : import

I have stored the result in a variable called ‘var’ and used ASSIGN activity
var=extractdatatabe.Select(“item=‘levis’ AND business=‘import’”)
and now my requirement is that : I have to get the PRICE of the above filtered output.

ie… I have to get the price of ‘levis’ item which comes under business ‘import’

I have attached a sample csv file which is simiar to my “Extracted” data!!

Have been trying to solve this since 2,3 days… and finally came here for your help…
No other way xD…
Please help me to get this solved!!!

@UnicornStark, Use the following query,

StringArray = (From row in dt.AsEnumerable()
Where row(“item”).ToString.Equals(“levis”) and row(“business”).Tostring.Equals(“import”)
Select Convert.ToString(row(“Price”))).ToArray()

Regards,
Dominic :slight_smile:

2 Likes

@599712 Thanks for the immediate reply, Can you please tell me where should I use the query??
Is it inside the Assign activity?

@UnicornStark, Yes in Assign activity !

Regards,
Dominic :slight_smile:

Oops… String strArray ???
Didnt get that part… Is that the name of the variable in which the output of the extracteddatatable is stored??

@UnicornStark, Create a variable with a datatype as StringArray.

Regards ,
Dominic :slight_smile:

1 Like

Many thanks! This was pretty useful!

how can we sort out of data scraping?
for eg: in flipkart automation how can we sort acording to the price low to high?

Hi @Minto_Sunny

Welcome to forum

To sort the datatable after scrapping u can use Sort datatable activitiy with sorting method as ascending.

Regards

Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed:

thank you. i tried but it has’t work for me

What error u are getting ?

my output of outputdatatable id in string and i cannot sort string into datatable

So try this way

  1. Extract datatable using datascraping.

  2. Use excel application scope and inside it use write range to write the datatable.

Then again read it using read range and sort it uisng sort datatable activitiy.

Hope it helps

Regards

Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed: