Everything is in the title. I'm wondering if any one knows a quick and with reasonable memory demands way of randomly mixing all the lines of a 3 million lines file. I guess it is not possible with a simple vim command, so any simple script using Python. I tried with python by using a random number generator, but did not manage to find a simple way out.
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
Takes only a few seconds in Python:
This is the same as Mr. Kugelman's, but using vim's built-in python interface:
Here is another way using random.choice, this may provide some gradual memory relieve as well, but with a worse Big-O :)
The following Vimscript can be used to swap lines:
Select the function in visual mode and type
:@"
then execute it with:call Random()
On many systems the
sort
shell command takes-R
to randomize its input.Here's another version
At the shell, use this.
decorate.py
undecorate.py
Uses almost no memory.