On 2/24/12 1:32 PM, Volker Braun wrote:
We do get questions about "how to read matrix from csv" quite regularly.
Of course its just a few lines of code, but I think it would be nice to
have a matrix_from_file('fname.csv') function that imports csv and
perhaps others (gnumeric/ooffice/excel). Any volunteers? ;-)


How about the matrix constructor reads from an iterator and recognizes csv? We could even use the numpy savetxt and loadtxt functions to more sophisticated parsing.

So:

with open('mymatrix.csv','r') as f:
    m=matrix(f)

or

m.save('test.csv') # or m.save('test.csv', format='csv')

I'm not volunteering in these suggestions...

Thanks,

Jason


--
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

Reply via email to