Your format string is missing some format characters. Try something like
fmt='%.4e%+.4ej %.4e%+.4ej %.4e%+.4ej'
But it looks like you'll need numpy 1.7.0 or later; see https://github.com/numpy/numpy/commit/1475319160baed782daa39e0de0c0655c2abe4b5
It worked for me with numpy 1.8.0, but not with 1.6.1.
With numpy 1.6.1, you can save the data in this format by first creating a real view of the complex data.
In this example (an ipython session), I'm using numpy 1.6.1:
In [28]: np.__version__ Out[28]: '1.6.1'
z is a complex array, with shape (2, 3):
In [29]: z Out[29]: array([[ 1.+2.j, -3.+4.j, 5.-6.j], [-1.+0.j, 0.+2.j, 3.+0.j]])
Use the view method to create a real array with shape (2, 6):
In [30]: rz = z.view(float) In [31]: rz Out[31]: array([[ 1., 2., -3., 4., 5., -6.], [-1., 0., 0., 2., 3., 0.]])
Save the array using savetxt. The format string uses the entire row, so there is no need to give the delimiter argument:
In [32]: savetxt('z.txt', rz, fmt='%.4e%+.4ej %.4e%+.4ej %.4e%+.4ej')
Take a look at the output:
In [33]: !cat z.txt 1.0000e+00+2.0000e+00j -3.0000e+00+4.0000e+00j 5.0000e+00-6.0000e+00j -1.0000e+00+0.0000e+00j 0.0000e+00+2.0000e+00j 3.0000e+00+0.0000e+00j
This file can be read back into a numpy array with np.loadtxt or np.genfromtxt. To use loadtxt, it must be told that the data type is complex:
In [8]: loadtxt('z.txt', dtype=np.complex128) Out[8]: array([[ 1.+2.j, -3.+4.j, 5.-6.j], [-1.+0.j, 0.+2.j, 3.+0.j]])
genfromtxt works with the same arguments. genfromtxt can also attempt to determine the data type on its own, by giving the argument dtype=None. This works for complex values:
In [9]: genfromtxt('z.txt', dtype=None) Out[9]: array([[ 1.+2.j, -3.+4.j, 5.-6.j], [-1.+0.j, 0.+2.j, 3.+0.j]])
numpy.__version__.)