I have a matrix of float numbers which i'm trying to write into a csv file, however csv writer writes it in scientific notation, i would like to leave the numbers in the original notation, i tried adding "%.2f" % but that resulted in the following error:
"TypeError: only length-1 arrays can be converted to Python scalars"
for item in string_color_Values:
avg_color_values = [ float(item) for item in string_color_Values]
array1t = np.array(avg_color_values)
np.savetxt("test.csv", array1t, delimiter=",")
original:
[ 0.5258 1. ]
[ 0.528 1. ]
[ 0.5486 1. ]
[ 0.5545 1. ]
[ 0.732 1. ]
[ 0.7872 1. ]
[ 1. 1. ]]
Csv which i obtain:
1.2270000000035e-01,1.0000000000e+00
2.7639999999790e-01,1.0000000000e+00
etc..
numpysoley to write a CSV file? You should just use thecsvmodule.np.savetxt("test.csv", array1l, "%f.2", delimiter=",")works for me.