
Hi every body! I have a &b numpy arrays a=np.loadtxt('çm1.txt', dtype=np.float, skiprows=2,usecols=[1]) b=np.loadtxt('çm1.txt', dtype=('x', np.float64), skiprows=2,usecols=[2]) 1. I want to save or write these two arrays and able to see the output as output file, say cm1.out. what about if I have multiple files like cm1.txt,cm2.txt,cm3.txt etc and to produce their corresponding outputs cm1.out,cm2.out,cm3.out etc. I appreciate your help

How do you want the output files to be formatted? Binary data? Textual representation? This function can do both: http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.tofile.htm... And numpy supports a variety of methods for outputting to files (and reading data back in): http://docs.scipy.org/doc/numpy/reference/routines.io.html --PLR On Fri, Jun 8, 2012 at 11:04 AM, bob tnur <bobtnur78@gmail.com> wrote:
Hi every body! I have a &b numpy arrays a=np.loadtxt('çm1.txt', dtype=np.float, skiprows=2,usecols=[1]) b=np.loadtxt('çm1.txt', dtype=('x', np.float64), skiprows=2,usecols=[2])
1. I want to save or write these two arrays and able to see the output as output file, say cm1.out. what about if I have multiple files like cm1.txt,cm2.txt,cm3.txt etc and to produce their corresponding outputs cm1.out,cm2.out,cm3.out etc.
I appreciate your help
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Hi every body! I have a &b numpy arrays a=np.loadtxt('çm1.txt', dtype=np.float, skiprows=2,usecols=[1]) b=np.loadtxt('çm1.txt', dtype=('x', np.float64), skiprows=2,usecols=[2])
how to save multiple files like cm1.txt,cm2.txt,cm3.txt etc and to produce their corresponding outputs cm1.out,cm2.out,cm3.out etc.
or how to modify this: np.savetxt(*fname*, *(a*,b), *fmt='%4*.8f*'*)
I appreciate your help

On Sat, Jun 9, 2012 at 2:12 PM, bob tnur <bobtnur78@gmail.com> wrote:
how to save multiple files like cm1.txt,cm2.txt,cm3.txt etc and to produce their corresponding outputs cm1.out,cm2.out,cm3.out etc.
or how to modify this: np.savetxt(fname, (a,b), fmt='%4.8f')
You can save them to separate files with a for loop. for i, arr in enumerate([a, b]): fname = 'cm{}.out'.format(i + 1) np.savetxt(fname, arr, fmt='%4.8f')
participants (2)
-
bob tnur
-
Patrick Redmond