Vincent Nijs schrieb: > If there is an easy way to read array data + variable names using the csv > module it would be great if that could be added to cookbook/InputOutput. I > couldn't figure out how to do it. > >
Hi Vincent, of course it depends a little on how exactly your csv file looks like, but if you just have column headers and the actual data, you might try something like the following: import csv from numpy import mat # or array if you like file_to_read = file(filename, 'r') read_from = csv.reader(file_to_read, skipinitialspace = True) obslist = [] datalist = [] for line in read_from: obslist.append(line[0]) datalist.append(line[1:]) file_to_read.close() # (datalist should now be a nested list, first index rows, second # columns) # (still contains the headers) varnames = datalist.pop(0) # now the real data data = mat(datalist, dtype = float) -sven _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion