[SciPy-user] fromfile, item, what other output than stdout / stderr is used ?

Stef Mientki s.mientki@ru...
Mon May 11 13:41:04 CDT 2009

thanks Paul, Robert,

Robert Kern wrote:
> On Sun, May 10, 2009 at 05:02, Stef Mientki <s.mientki@ru.nl> wrote:
>> hello,
>> I'm using "fromfile" to read data from a file generated by another program.
>> The data is read on the same operating system as where the file was created.
>> I use on several locations, at the procedure seems to run very well, but ...
>> ... when run the program from the normal window command box,
>> I get an error message:
>>    "40 items requested but only 10 read"
>> Normally I run all the programs with either a hidden command window or
>> from some kind of IDE.
>> In the IDE, stdout and stderr are redirected, and I see all print
>> commands and errors in the redirection window,
>> but I don't see the above error message from numpy.
>> So it seems that numpy is using a third kind of output device.
>> ???
> IDLE redirects sys.stdout and sys.stderr. It does nothing with the C
> stdout and stderr file handles. Presumably we are printing stuff out
> from the C level using printf(). We probably should be using the
> Python API function for printing to sys.std*. Patches welcome.
Sorry but I've chosen Python, because I found C too difficult.
>> Now from the documentation at
>>  http://docs.scipy.org/doc/numpy/reference/generated/numpy.fromfile.html
>> I read:
>> numpy.fromfile(/file/, /dtype=float/, /count=-1/, /sep=''/)
>> *count* : int
>>    Number of items to read. -1 means all items (i.e., the complete file).
>> What is a item ?
>> Is it in bytes, or as in my case, where dtype is an 32 bit integer, in
>> integers (which I would read from the documentation) ?
> An item is one instance of the dtype.
>> Well it must be a byte I guess,
>> because if I use bytes as the count, the program is working well,
>> but I get the above error message in the windows command window.
> Since the number of bytes is greater than the number of items and you
> are getting errors suggesting that you have requested more items than
> there are available in the file, I really don't understand how this
> sentence can be true.
Your absolutely right.
The error was caused by using the requested count later on,
which I've now replaced by the real fetched count.


More information about the SciPy-user mailing list