1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Development Text file line randomiser

Discussion in 'Software' started by JB, 21 Jan 2005.

  1. JB

    JB What's a Dremel?

    Joined:
    26 Aug 2002
    Posts:
    414
    Likes Received:
    0
  2. jezmck

    jezmck Minimodder

    Joined:
    25 Sep 2003
    Posts:
    4,456
    Likes Received:
    36
    open it in excel - make sure you import it so that each line goes in a new row.
    add a column of random numbers
    sort it by the random numbers
    copy, paste the urls back into the text file.

    hth
     
  3. Hwulex

    Hwulex Minimodder

    Joined:
    1 Feb 2002
    Posts:
    4,007
    Likes Received:
    1
    Theoretically, this should work, but in practice you seem to get the same result from shuffle() every time. :sigh:

    (It was more compact than this (ie; two lines) but due to differing php function returns, it had to be expanded :blah: )

    PHP:
    $chrFile './urls.txt';
    $arrURLs file($chrFile);
    shuffle($arrURLs);
    $resFile fopen($chrFile'w+');
    fwrite($resFilestr_replace("\n\n"""implode("\n"$arrURLs)));
    fclose($resFile);
    (I made the assumption that seeing as the last of your threads I answered was a PHP question, that PHP would be an ok language to solve this with)
     
  4. simon w

    simon w What's a Dremel?

    Joined:
    3 Nov 2003
    Posts:
    1,302
    Likes Received:
    0

    That's probably because you haven't provided a seed for the random number generator.

    Edit: Use php's php's srand function
     
    Last edited: 21 Jan 2005
  5. Hwulex

    Hwulex Minimodder

    Joined:
    1 Feb 2002
    Posts:
    4,007
    Likes Received:
    1
    Hence why I was a little miffed. ;)
     
  6. jezmck

    jezmck Minimodder

    Joined:
    25 Sep 2003
    Posts:
    4,456
    Likes Received:
    36
    so JB, do you have a target language? do you need it done automatically?
     
  7. JB

    JB What's a Dremel?

    Joined:
    26 Aug 2002
    Posts:
    414
    Likes Received:
    0
    The php thing worked a treat :) Thanks i can now do it automatically :)
     
  8. John Cena

    John Cena What's a Dremel?

    Joined:
    1 Jun 2004
    Posts:
    818
    Likes Received:
    0
    I would instead put a number before the url ex.

    1
    google.com
    2
    bittech.net
    3
    something.com

    pesudeo code
    generate random number
    read until end of file
    if line = random number then
    read one more line into a string and that is your random url
     

Share This Page