![](https://secure.gravatar.com/avatar/1e2c37bcaef31873acac4fa23d90cc01.jpg?s=120&d=mm&r=g)
Dear Group, I've just started to use numarray as I have an imaging program I want to port. I noticed in the differences document that one can read in data using fromfile into an array. This is a great savings over using the standard , string to integer floats. For some strange reason I can't get it to work correctly with my interferometer file (512,512) array. So I made up a small set of data in a file.(Attached test.txt). The code I used was simple, inp = open('c:/transfer/test.txt','r') y=fromfile(inp,Int32,[4,4]) with the following error message(s) Traceback (most recent call last): File "<interactive input>", line 1, in ? File "C:\Python22\Lib\site-packages\numarray\numarray.py", line 380, in fromfile raise ValueError( ValueError: Not enough bytes left in file for specified shape and type Well I thought maybe Int32 is not the correct specification so I tried Int16 and Int8. These both worked but the numbers read in were wrong. So what am I not understanding here? Thanks Cliff Martin 0 -32678 14 85 342 12 14 15 16 45 67 98 38 256 234 234
![](https://secure.gravatar.com/avatar/faf9400121dca9940496a7473b1d8179.jpg?s=120&d=mm&r=g)
On Tue, 2003-06-24 at 19:06, Cliff Martin wrote:
Looking over your test data, it looks like it is in ASCII. fromfile() works with binary data. Reading in your data can be done with a few lines of Python code:
Binary files are easier and more efficient, but are not portable unless you remember the byte order. Todd -- Todd Miller <jmiller@stsci.edu>
![](https://secure.gravatar.com/avatar/faf9400121dca9940496a7473b1d8179.jpg?s=120&d=mm&r=g)
On Tue, 2003-06-24 at 19:06, Cliff Martin wrote:
Looking over your test data, it looks like it is in ASCII. fromfile() works with binary data. Reading in your data can be done with a few lines of Python code:
Binary files are easier and more efficient, but are not portable unless you remember the byte order. Todd -- Todd Miller <jmiller@stsci.edu>
participants (2)
-
Cliff Martin
-
Todd Miller