Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Simple script to Shuffle a list of emails.

I have a simple request for help on coding a script to Shuffle a list of Email:Pass format.

Unsure if posting links is allowed but for reference, exactly what this site does.
Spoiler (Click to View)

PM me if you don't mind helping, can pay if needed.

Cheers lads. 👍
On Vacation, won't be able to reply for 2 weeks.
I think Bash is better tool for this job:

Code
cat input.txt | shuf > output.txt

Stupid Python one-liner:

Code
cat input.txt | python -c "import sys,random; print(''.join(sorted(sys.stdin.readlines(), key=lambda k: random.random())))" > output.txt
(Jul 4, 2019 05:44 PM)l0lwtf Wrote:  I think Bash is better tool for this job:

Code
cat input.txt | shuf > output.txt

Stupid Python one-liner:

Code
cat input.txt | python -c "import sys,random; print(''.join(sorted(sys.stdin.readlines(), key=lambda k: random.random())))" > output.txt

Good suggestion, your `.readlines()` will still take in the `\n` so you might want to do a `.read()` and `.striplines()` like in my example.
Snxp App - ONLY $29.99
Your best option to upload snaps to Snapchat!

✔️ Trusted by over 500 members
✔️ Operational for over a year

/307lyz5]BUY NOW
(Jul 5, 2019 06:25 AM)PornFlakes Wrote:  your `.readlines()` will still take in the `\n` so you might want to do a `.read()` and `.striplines()` like in my example.

Nope, by using ''.join() instead of '\n'.join() I can join the elements as-is, that is, with each of them already suffixed by '\n' due to readlines(), so, I don't have to add them during the .join().

I think the only change between our 2 examples is that I print an extra newline which technically is more wrong :-)
(Jul 5, 2019 06:36 AM)l0lwtf Wrote:  Nope, by using ''.join() instead of '\n'.join() I can join the elements as-is, that is, with each of them already suffixed by '\n' due to readlines(), so, I don't have to add them during the .join().

I think the only change between our 2 examples is that I print an extra newline which technically is more wrong :-)

The last line of the input file might not have a newline, this is why you want to clean up user input by stripping newlines and add them in later.
Snxp App - ONLY $29.99
Your best option to upload snaps to Snapchat!

✔️ Trusted by over 500 members
✔️ Operational for over a year

/307lyz5]BUY NOW
(Jul 4, 2019 03:39 PM)PornFlakes Wrote:  Do you want to shuffle the positions of the email:pass lines or do you want to shuffle the emails with different passwords?


edit:

pretty sure something like this will do the trick

Code
import random

lines = open('input.txt').read().splitlines()
random.shuffle(lines)

with open('output.txt', 'w') as f:
   f.write('\n'.join(lines))

print('%s lines shuffled.' % len(lines))

Just the positions, same email:pass. This worked great, thank you very much mate.
On Vacation, won't be able to reply for 2 weeks.
If you're going to use this in production I would use the Bash command. It is more performant and less code.

Code
cat input.txt | shuf > output.txt


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Ineed2learn2eatJul 13, 2017 10:48 AM 3 230 Jul 13, 2017 10:48 AM
Last Post: Ineed2learn2eat
[Python] by B0PSFeb 15, 2017 07:11 AM 5 157 Feb 15, 2017 07:11 AM
Last Post: Riԁdle
[C] by Mad HatterNov 23, 2016 06:26 PM 3 419 Nov 23, 2016 06:26 PM
Last Post: REDRIFLE