Python Forum
How to generate Lines from wordlist? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to generate Lines from wordlist? (/thread-21944.html)



How to generate Lines from wordlist? - python7777 - Oct-22-2019

Hello guys,
I'm new here ^^

I have a question , So I've got a big textfile with words
I'm trying to Generate every possible combination from all of them
For example : textfile contains this words : abc , abd , abe , abh ....
this will generate
abc abd abe abh
abc abd abe abg
....
abd abc abe abh
......
every possible line for each starting word
etc etc...
(I have tried to this with crunch but it needs 1000PB ;D)
The main question is , Is there some one who created something like this And can possibly share his script?
I sometimes need 3 words per line , sometimes I need more (so I need to input how many words per line)
If there is no such a script can some one reffer me to where I should start?
Also a stop and resume would be nice! since this will take so much space I will need to constantly Delete the old one and recreate a new one.

Thanks a bunch! ^_^


RE: How to generate Lines from wordlist? - ichabod801 - Oct-22-2019

The itertools module has the permutations and combinations functions. They create generators, which return one combination/permutation at a time, without storing all of them in memory. You could write them to a file in append mode, and then start a new file every n-thousand lines.