This is not what I want. sage: !cat file1 1 3 2 0 3 10 sage: !cat file2 1 29 2 21 3 -19 sage: a=numpy.loadtxt('file1') sage: b=numpy.loadtxt('file2')
sage: out = a <some magic function> b sage: out array([[ 1., 3. ,29], [ 2., 0. ,21], [ 3., 10. ,-19]]) On Sun, Nov 1, 2009 at 3:02 AM, Jason Grout <jason-s...@creativetrax.com>wrote: > > yotama9 wrote: > > Hello. > > > > I have several files of data that I want to merge into a single array > > and then manipulate it (adding a single column to all the column > > etc.) > > > > Each file is constructed of two columns. I want to take the columns of > > the first file and add to the the second column of each file. > > > > Is there a way to do so? > > Personally, I would use numpy and numpy.loadtxt for this sort of thing: > > sage: !cat file1 > 2 3 > 1 0 > 3 10 > sage: !cat file2 > 23 29 > 20 21 > 3 -19 > sage: import numpy > sage: a=numpy.loadtxt('file1') > sage: a > > array([[ 2., 3.], > [ 1., 0.], > [ 3., 10.]]) > sage: b=numpy.loadtxt('file2') > sage: b > > array([[ 23., 29.], > [ 20., 21.], > [ 3., -19.]]) > sage: a+b > > array([[ 25., 32.], > [ 21., 21.], > [ 6., -9.]]) > > Jason > > > -- > Jason Grout > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---