python - Creating N-dimensional dynamical array based on user's input? -
an ascii file has 61 columns, columns read using readlines(). user has option specify how many columns use create n-dimennsional array based on his/her choice of number of columns.
i want create dynamic n-dimensional array such as:
from numpy import * file = open('test.txt','rb') choice = float(raw_input('how many columns want use: \t')) = [[],[],[],...] # n-dimensional array (rows = 486, columns = n) such has dimensions based on user's choice 'choice'. 'n' can change between 1 , 61. how go doing this?
-thanks!
>>> rows = 486 >>> columns = 5 >>> = [[none] * columns x in xrange(rows)] >>> len(a) 486 >>> len(a[0]) 5
Comments
Post a Comment