I have attached one of the files, try to sort and let me know the results. Kindly sort by date. ooops - am told the file exceed 25M.<div><div><br></div><div>below is the code</div><div><br></div><div><div>import glob</div>
<div>txtfiles =glob.glob('*.txt') </div><div>import dateutil.parser as parser</div><div><br></div><div><br></div><div>for filename in txtfiles:</div><div> temp=[]</div><div> f=open(filename)</div><div> for line in f.readlines():</div>
<div> line = line.strip()</div><div> line=line.split()</div><div> temp.append((parser.parse(line[0]), float(line[1])))</div><div> temp=sorted(temp)</div><div> with open(filename.strip('.txt')+ '.sorted', 'wb') as p:</div>
<div> for i, j in temp:</div><div> p.write('%s %s\n' %(str(i),j))</div></div><div><br><div><br><div class="gmail_quote">On Sun, May 6, 2012 at 6:21 PM, Devin Jeanpierre <span dir="ltr"><<a href="mailto:jeanpierreda@gmail.com" target="_blank">jeanpierreda@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sun, May 6, 2012 at 12:11 PM, J. Mwebaze <<a href="mailto:jmwebaze@gmail.com">jmwebaze@gmail.com</a>> wrote:<br>
> [ (datatime, int) ] * 1172026<br>
<br>
I can't duplicate slowness. It finishes fairly quickly here. Maybe you<br>
could try posting specific code? It might be something else that is<br>
making your program take forever.<br>
<br>
>>> x = [(datetime.datetime.now() + datetime.timedelta(random.getrandbits(10)), random.getrandbits(32)) for _ in xrange(1172026)]<br>
>>> random.shuffle(x)<br>
>>> x.sort()<br>
>>><br>
<span class="HOEnZb"><font color="#888888"><br>
-- Devin<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><font style="color:rgb(0,51,0)" size="1"><b>Mob UG: +256 (0) 70 1735800 | NL +31 (0) 6 852 841 38 | Gtalk: jmwebaze | skype: mwebazej | URL: <a href="http://www.astro.rug.nl/~jmwebaze" target="_blank">www.astro.rug.nl/~jmwebaze</a><br>
<br>/* Life runs on code */</b></font><br><br>
</div></div></div>