Newsgroups: comp.lang.python
From: Simon Brunning <simon.brunn...@gmail.com>
Date: Tue, 8 Mar 2005 14:28:09 +0000
Local: Tues, Mar 8 2005 9:28 am
Subject: Re: shuffle the lines of a large file
On Tue, 8 Mar 2005 14:13:01 +0000, Simon Brunning
<simon.brunn...@gmail.com> wrote: I couldn't resist. ;-) > On 7 Mar 2005 06:38:49 -0800, g...@ll.mit.edu <g...@ll.mit.edu> wrote: > > As far as I can tell, what you ultimately want is to be able to extract > > a random ("representative?") subset of sentences. > If this is what's wanted, then perhaps some variation on this cookbook > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/59865 import random def randomLines(filename, lines=1): for line_index, line in enumerate(open(filename)): return selected_lines This has the advantage that every line had the same chance of being -- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||