Extract table data not working correctly

Hello everyone,

extarct table data repeats some data, that is, it writes some data more than once, as you can see in the picture, how do I prevent this?

@lakshman
@lrtetala
@mkankatala
I can’t figure it out, could you help me pls :smiling_face_with_tear:

Hi @emir_ozsimsir

Datatablevaraible.AsEnumerable().GroupBy(Function(i) i.Field(Of String(“columnName”)).Select(Function(g) g.First).CopyToDataTable

HOPE This helps

1 Like

I am new to UiPath, can you tell me how I should use this code?

Yes

You can place it in assign activity
Leftside datatablevariable=rightside place the above query

1 Like

it didn’t work, it gives me an error, did I do something wrong?

Datatablevaraible.AsEnumerable().GroupBy(Function(i) i(“columnName”)).Select(Function(g) g.First).CopyToDataTable

First try with above query if not works use below

Datatablevariable.defaultview.totable(true)

Can you use this

1 Like

the second code you gave worked but I didn’t get the result I wanted. it deleted everything that was the same with each other, I don’t want this because sometimes one or two data can be the same (the numbers you see in the picture are the price list of ford cars). what I want to do is to prevent extract table data from reading the same data more than once.

thanks for your advice.

I Think before writing it to excel use the above query so that you will get the expected output

Cheers

1 Like

I guess you didn’t understand what I said, let me explain with an example. extract table data writes a 2016 model vehicle with a price of 4000 dollars 3 times when it should write the vehicle once. at the same time, a 2017 model ford vehicle is also worth 4000 dollars if I use the code you gave, the price of the 2017 model vehicle will be deleted. what I want to do is to write the price of 2016 and 2017 model vehicles, although their prices are the same, and to prevent extract table data from writing the same data 3 times.

I apologize for my bad English.

Hi @emir_ozsimsir
For that you need to make your datatable should have atleast two columns of with model vehicle other column with dollar values

1 Like

Yes, you are right, it can be solved in this way and I tried it, but extract table data repeats the same way when writing the models, so the models are written in the wrong lines and the prices do not match. I think I need to find a different way.

thanks for the help.

Can you share the sample data which you are getting with full columns

1 Like

@emir_ozsimsir

Can you preview the data in extract datatable and check if they are actually repeated or that is the exact data…

Ideally there wont be any repeatition

Cheers

1 Like

@Anil_G

890000 should come after 960000, but 850000 is written for the second time.

I am trying to get the prices on the second hand car sales site, I save all prices on 14 pages to excel.

here is the website I use
https://www.sahibinden.com/ford-focus-1.6-ti-vct/otomatik?a5_min=2015

this is the excel file I saved
ford.xlsx (16.1 KB)

Hi @emir_ozsimsir
After extracting the data table use Remove Duplicate Rows activity

image

O/P Excel:

ford (1).xlsx (19.2 KB)

I hope you understand!!

1 Like

@emir_ozsimsir

  1. Try getting remainign columns also and check if it is same or may be there is some hidden element in between
  2. If same then can use Remove duplicates activity…but for that would suggest extra as many columns as possible so that only duplicate are removed and after that can use filter datatable to get only the columns you need

cheers

If I use the remove duplicate activity, I will have removed all the vehicles with the same price and the same year, in short, in the photo I threw, the number of vehicles says 272 vehicles, there should be 272 vehicles in the file I saved, in the excel file you threw, all vehicles that do not repeat but have the same year and price are deleted.

https://www.sahibinden.com/ford-focus-1.6-ti-vct/otomatik?a5_min=2015

Hi @emir_ozsimsir ,

What is the Row Count received for the Datatable after using the Remove Duplicate Rows Activity ?

Also, If there are multiple Vehicle Name searches to be performed, would suggest to add the name of the Vehicle also to the Datatable and then Perform the Remove Duplicate Rows activity so that we can maintain the uniqueness of data as required.