The answer to my problem is using the dtype
for unicode strings (U2
, for example).
Thanks to the answer of E.Kehler, I found the solution.
If I use str
in place of S8
in the dtype
definition, then the output for the 2nd column is empty:
numpy.genfromtxt("test.csv", delimiter=",", dtype='f8,str')
the output is:
array([(1.0, ''), (2.0, ''), (3.0, '')], dtype=[('f0', '<f16'), ('f1', '<U0')])
This suggested me that correct dtype
to solve my problem is an unicode string:
numpy.genfromtxt("test.csv", delimiter=",", dtype='f8,U2')
that gives the expected output:
array([(1.0, 'a'), (2.0, 'b'), (3.0, 'c')], dtype=[('f0', '<f16'), ('f1', '<U2')])
Useful information can be also found at the numpy datatype doc page .