Re: [Tutor] reading a string into an array

2008-06-01 Thread Kent Johnson
On Sun, Jun 1, 2008 at 7:03 AM, bob gailer <[EMAIL PROTECTED]> wrote: > Even more concise and possibly faster: > > data = open('out.out').read().replace('\n', '\\').split('\\') Or use re.split() to split without the replace: import re data = open('out.out').read() data = re.split(r'[\n\\]',

Re: [Tutor] reading a string into an array

2008-06-01 Thread bob gailer
Kent Johnson wrote: On Sat, May 31, 2008 at 3:43 PM, Bryan Fodness <[EMAIL PROTECTED]> wrote: I am trying to read a long string of values separated by a backslash into an array of known size. Here is my attempt, from numpy import * ay, ax = 384, 512 a = zeros([ay, ax]) for line in open('out

Re: [Tutor] reading a string into an array

2008-05-31 Thread Kent Johnson
On Sat, May 31, 2008 at 3:43 PM, Bryan Fodness <[EMAIL PROTECTED]> wrote: > I am trying to read a long string of values separated by a backslash into an > array of known size. > > Here is my attempt, > > from numpy import * > ay, ax = 384, 512 > a = zeros([ay, ax]) > for line in open('out.out'): >

[Tutor] reading a string into an array

2008-05-31 Thread Bryan Fodness
I am trying to read a long string of values separated by a backslash into an array of known size. Here is my attempt, from numpy import * ay, ax = 384, 512 a = zeros([ay, ax]) for line in open('out.out'): data = line.split('\\') k = 0 for i in range(ay): for j in range(ax): a[i, j