[SciPy-user] efficiently importing ascii data
dd55 at cornell.edu
Mon Nov 14 08:47:44 CST 2005
On Monday 14 November 2005 08:10 am, Bill Dandreta wrote:
> Darren Dale wrote:
> >I was wondering if the fromstring function could be expanded to include
> > ascii strings. Right now, I'm considering reading my messy file, creating
> > a neatly formatted string, writing that string back into a temporary
> > file, and then using the fromfile function. It would be so much nicer to
> > just create the array from the string itself.
> You might be able to use an 'in memory file' using StringIO from the
> StringIO module.
I don't think fromfile plays nice with StringIO:
from scipy import *
from StringIO import StringIO
# at this point, the file-like object f should be ready for reading
Traceback (most recent call last):
File "test.py", line 5, in ?
IOError: first argument must be an open file
More information about the SciPy-user