How pick randomly 1000 rows from datatable where datatable contains 10k

Hi Team,

I have an excel with 10000 records and i want to form a other datatable with only 1000 records where 1000 picked randomly from whole datatable. Bot should not pick top 1000 or last 1000. Please help me on this.

Thanks in advance…!!

Try this;

  1. Order the rows in a data table randomly.

  2. Take the 1000 rows from the randomly ordered data table.

    Dim rand = New Random()
    Dim employees = employee.AsEnumerable().OrderBy(Function(rn) rand.Next).Take(10)

Regards,
Karthik Byggari

2 Likes

Hi Kathik,

Using above syntax i’m getting top rows only it is not picking randomly.
Please see the image.

How many rows are in dt1?

total 5 rows

image

when printing using for each row always first 3 rows only printing.

image

Can you please try with more than 10 rows and let me know if the result is same.

Yes results are same.

@nagarameshkola

Welcome to the uipath community.

Please check below thread and give it a try once.

https://forums.asp.net/t/1538901.aspx?How+to+get+the+unique+records+randomly+from+Data+Table+

Okay. Let me check from my side and let you know the output.

Regards,
Karthik Byggari

Hi,
I am also getting only the top rows

Is there any solution to this?

Hi @Needhelp

Wait I will check and let you know the findings.

Hi @Needhelp

I posted a custom activity in the UiPath Connect.

Please download the package from here -

https://connect.uipath.com/marketplace/components/get-random-rows-datatable-extensions

It will be soon available in the Manage Packages.

Regards,
Karthik Byggari

Hi,

It says that the resource does not exist

Oops. Can you send me the error screenshot to analyse.

I guess the component is in review. I will let you know once it is available in connect.
Sorry for delay.