[Tutor] Appending an extra column in a data file

Andre' Walker-Loud walksloud at gmail.com
Wed Apr 10 20:06:46 CEST 2013


Hi Sayan,

> Yup it's exactly what I want!
> 
> I want many data files,not one...to make an animation out of it. For a data file t is constant.

You should not need many data files to make an animation.  If you write your loops correctly, you can take a single data file with all the data.  If you are using code you did not write, and just want to get it to work, I understand that, but would encourage you also to figure out how to do it all with single data file.  Less files makes a files system and user happier.

> the solution you have just mentioned i.e np.array([t,pp_za,pv_za]) is giving the following error:
> 
> 
> Traceback (most recent call last):
>   File "ZA_Phase_Plot.py", line 38, in <module>
>     np.savetxt(fname, np.array([pp_za,pv_za,t]).T, '%f')
>   File "/usr/lib/python2.7/dist-packages/numpy/lib/npyio.py", line 979, in savetxt
>     fh.write(asbytes(format % tuple(row) + newline))
> TypeError: float argument required, not numpy.ndarray
> 
> What to do? :-|

There are pieces of the code snipet you sent which are not defined, so it is not clear why you are getting this error.  How long is the file "ZA_Phase_Plot.py"?  At least you can send from line 0 to where you did before, so all the variables are defined.  That should help.

Andre





More information about the Tutor mailing list