[Numpy-discussion] Need **working** code example of 2-D arrays

John Hunter jdh2358 at gmail.com
Mon Oct 13 16:04:06 EDT 2008


On Mon, Oct 13, 2008 at 2:29 PM, Alan G Isaac <aisaac at american.edu> wrote:

> The problem is, you did not just ask
> for technical information.  You also
> accused people of being condescending
> and demeaning.  But nobody was
> condescending or demeaning.  As several
> people **politely** explained to you,
> you are wrong about that.

Here is a simple example of loading some 2D data into an array and
manipulating the contents

import numpy as np
# load a 2D array of integers
X = np.loadtxt('somefile.txt').astype(int)
print X.shape  # X is a 2D array

# display the contents of X as a string
print '\n'.join([''.join([chr(c) for c in row]) for row in X])

The input file "somefile.txt" is attached

JDH
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: somefile.txt
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20081013/9ea9e741/attachment.txt>


More information about the NumPy-Discussion mailing list