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

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -