Jump to content
UBot Underground

shuffling a table


Recommended Posts

Ive been searching and seen a lot about shuffling lists but how would I go about shuffling a table.

 

I made a bot and it pulls various data (emails, account names, proxy, browser, refferer etc) from a csv file, then it loads it into a table.

 

The bot then uses that data for each account.

 

How would I go about randomizing that each row is randomized before the bot starts?

Link to post
Share on other sites

You'll have to loop through the already existing data, randomly, and add it to a new table if you want the result shuffled per se, in a file or a matrix/vector like a table or list...

 

However, if you don't want that but only to use randomly chosen data from the file, it could be a bit easier.

 

In both cases you need to make sure that you choose only from the not-chosen-yet part, so for each looping cycle, the random position that you generate must come from an ever shrinking interval.

 

Say you have 10 combos.

 

The first step could choose randomly from all the 10 available,

but on second step, you need to remove the one already chosen and then choose only from the 9 left...

 

If you have a large enough data source file and plan on using only a small fraction of it, then instead of the above method, you could just generate a random number from the whole interval and simply check if it was chosen before or not, w/o many chances to slow you down significantly due to re-selections.

 

However, if you have a close match between the number of accounts in the data file and the total number of iterations, it is a MUST to eliminate the ones chosen before, or else your bot will become useless after looping for a while, as many random numbers would hit the same positions again and again.

 

The BEST solution to this would be a RAND function in UBot that would generate only UNIQUE results in a given interval when iterating for a number of times... :P (I wish...)

Link to post
Share on other sites

One other thing...

 

Due to the lack of an UBot command to delete rows from a table... the best way would be to load the data from your file rather in a list format than a table.

 

That way, as soon as you selected a list position randomly, you can copy it (use it) and then delete it from the list and decrease the randomizing interval accordingly.

Link to post
Share on other sites

Maybe you don't need to sort the table, just choose a random row. You could do something like this:

 

set(#random row, $rand(1, $table total rows(&table)), "Global")

 

and then use that #random row variable when referring to the cell.

 

:rolleyes:

  • Like 1
Link to post
Share on other sites

Thanks guys

 

Duane Im looking at your idea and it looks good but would that not repeat rows? I would only want each row (account) to be ran once.

 

Vaultboss, Isnt a list just one list of items. Would I not need several lists, one for each column of my spreadsheet.

 

For example to simplify things lets just say I need username and pass and then i randomize the username list, how would I make my password list be randomized the same way.

 

As for your first suggestion about looping through the table and making a new one, again Im not really sure how that would be done to be honest as the way I see it now it would go over the same data. Maybe Im missing something here, Im jsut kindof confused as to how to prevent the rand command going over the same data.

Link to post
Share on other sites

Without tooting my own horn here I do teach others how to use the components with UBot Studio. And I give complete examples to accomplish such Table feats. I even have a couple of work-arounds for dealing with Tables; like "How to Delete a Row" and How to Delete a Column"

 

To shore up what Duane gave you could setup a list to save your random selections so as not to re-use them.

Link to post
Share on other sites

To shore up what Duane gave you could setup a list to save your random selections so as not to re-use them.

Yep, that's what I said, too

 

First, you need to forget about working with a table as a source of data, if you plan to choose randomly and never repeat, because the table related commands in UBot don't have a Delete Row command.

However, you can delete a list item.

 

Therefore, you need to read your file into a list instead of a table to start with

Next, you generate a random number between 0 and the max number of list elements

 

You select the corresponding list element (row/line whatever you call it)

You move that element to another list (shuffled) OR just add it at the bottom of the current list

AND

also, delete the element (row) you have already randomly selected.

 

Next, you decrement the max number of randomizable lines (as you already used ONE element in the current step, the next step will have one element less, correspondingly)

 

...and continue looping till you finish.

 

Now, to make it clear... a list element is not necessarily one of your variables (either username OR password) etc..

BUT it can actually be a combo of all those, separated by comma, just as they would have been table cells on a single row and the list you load from a csv file will have these rows (elements) containing all your needed data to login, in a single line.

 

BUT that doesn't matter

 

Once you shuffled all the list you save it to a file and load it bak as a table this time and work just as you want it.

 

HTH

Link to post
Share on other sites

thanks guys, will take a read now and have a play around.

 

To clarify though, this is an example of my csv file.

 

NAME PASSWORD USER AGENT PROXY

name1 pass1 firefox 172.11.12.21

name2 pass2 IE 106.12.1.1

name3 pass3 chrome 121.131.141.12

 

If I were to put each column in a list wouldn't each row get jumbled and it would end up using the wrong password to each username?

Link to post
Share on other sites

Yep, that's what I said, too

 

First, you need to forget about working with a table as a source of data, if you plan to choose randomly and never repeat, because the table related commands in UBot don't have a Delete Row command.

However, you can delete a list item.

 

Therefore, you need to read your file into a list instead of a table to start with

Next, you generate a random number between 0 and the max number of list elements

 

You select the corresponding list element (row/line whatever you call it)

You move that element to another list (shuffled) OR just add it at the bottom of the current list

AND

also, delete the element (row) you have already randomly selected.

 

Next, you decrement the max number of randomizable lines (as you already used ONE element in the current step, the next step will have one element less, correspondingly)

 

...and continue looping till you finish.

 

Now, to make it clear... a list element is not necessarily one of your variables (either username OR password) etc..

BUT it can actually be a combo of all those, separated by comma, just as they would have been table cells on a single row and the list you load from a csv file will have these rows (elements) containing all your needed data to login, in a single line.

 

BUT that doesn't matter

 

Once you shuffled all the list you save it to a file and load it bak as a table this time and work just as you want it.

 

HTH

Sorry Vaulttboss

 

you posted that when I was typing so didnt see it till after.

 

I thihnk that has cleared up my confusion on lists. Didnt realise I could use a list like a table with commars.

 

Still going to have to play around a bit I think but if I can do this using lists rather than tables maybe it will make more sense to me.

  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...