On Friday, February 24, 2012 11:13:53 AM UTC+1, Chappman wrote: > > and then using a function which opens up the CSV file and utilizes the > entires in the matrix P, from the CSV file. > Is there a method for this?
uhm, i'm not sure if you ask about reading or writing. also, your "d" in def is uppercase. reading from this file matrix.csv: 1,2,3 2,2,-1.1 0,0,1 works like this: sage: import csv sage: data = list(csv.reader(file("matrix.csv"))) sage: m = matrix([[ float(_) for _ in line] for line in data]) sage: m [ 1.0 2.0 3.0] [ 2.0 2.0 -1.1] [ 0.0 0.0 1.0] the other way around works like this (i print this, writing to the file is trivial) for line in m.rows(): print ','.join((str(_) for _ in line)) gives 1.0,2.0,3.0 2.0,2.0,-1.1 0.0,0.0,1.0 h -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org