On Sun, Feb 5, 2012 at 10:41 AM, Paolo <p.zaff...@yahoo.it> wrote: > I solved using 'rb' instead of 'r' option in the open file task. > > that would do it, if it's binary data, but you might as well so it "right":
> matrix="".join(f.readlines()) > > readlines is giving you a list of the data, as separated by newline charactors ("\n") -- it was broken on Windows, because opening the file in text mode translated Windows newlines ("\r\n") to *nix style ones -- opening it in binary fixed that, but why use readlines at all? That's for text -- use read. However, even better is to use fromfile(), which creates an array form binary data in a file without puttin git in a string, first: > matrix = np.fromfile(f, dtype=np.int16) by the way -- be careful of endian issues here -- if you are moving data among different machines. You could specify the endian-ness, for instance: dt = numpy.dtype('<i2') for a 16 bit little-endian integer. -CHB -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion