Numeric array and for loops problem

Stan dragonscraft at yahoo.it
Mon Jan 6 11:56:28 EST 2003


Hi all
 I've made the following pice of code

		try:
			f = open(os.path.join("xxx", fname))
		except IOError:
			print "no such a file"
		else:
			lines = f.readlines()					
			worldy = len(lines)
			worldx = len(lines[0])/2
			worldarray = Numeric.zeros((worldy,worldx))
			y = -1 #***because arrays starts at 0***
			for line in lines:
				y += 1
				vals = split(line)
				x = -1  #***same as y***
				for val in vals:
					x += 1
					worldarray[x,y] = val
			f.close()

It should read some strings from a file and insert their value into
worldarray
The file is so strocturated:
Some string of numbers (all same lenght) all separated by whitespace.
But python give me this message error!!! I really can't understand
where's the matter? It's not possible such an assignment?
worldarray[x,y] = val
ValueError: array too large for destination




More information about the Python-list mailing list