Re: Need advice on reading contents of a file into memory

2006-03-15 Thread vinjvinj
Thanks. read() did not work when I opened the file with: f = open(someFilePath) But after changing to f = open(someFilePath, "rb") the read() works fine. VJ -- http://mail.python.org/mailman/listinfo/python-list

Re: Need advice on reading contents of a file into memory

2006-03-15 Thread Fredrik Lundh
"vinjvinj" wrote: > f = open(someFilePath, "rb") > content = [] > for data in content.read() >content.append(data) > fullContent = "".join(content) > > Is there a more efficient way of doing this? read reads until end of file, so unless the source is something unusual, a plain fullConten

Re: Need advice on reading contents of a file into memory

2006-03-15 Thread Felipe Almeida Lessa
Em Qua, 2006-03-15 às 13:49 -0800, vinjvinj escreveu: > f = open(someFilePath, "rb") > content = [] > for data in content.read() >content.append(data) > fullContent = "".join(content) > > Is there a more efficient way of doing this? I'll be running this > operation on 10,000+ files where each

Need advice on reading contents of a file into memory

2006-03-15 Thread vinjvinj
f = open(someFilePath, "rb") content = [] for data in content.read() content.append(data) fullContent = "".join(content) Is there a more efficient way of doing this? I'll be running this operation on 10,000+ files where each file is an image file with size 50k-100k -- http://mail.python.org/m