Le mardi 08 octobre 2019, Stephen P. Molnar a écrit : > > data = np.genfromtxt("13-7.log", usecols=(1), dtype=None, > > skip_header=27, skip_footer=1, encoding=None)print(data)[...] > > ['-8.839713733' '-8.743377250' '-8.151051167' '-8.090452911' '- > > 7.967494477' '-7.854890056' '-7.757417879' '-7.741557490' '- > > 7.643885488' '-7.611595767' '-7.507605524' '-7.413920814' '- > > 7.389408331' '-7.384446364' '-7.374206276' '-7.368808179' '- > > 7.346641418' '-7.325037898' '-7.309614787' '-7.113209147']
Hi, Note that your data array is made of strings and not floats. The default value of the dtype argument is float, which you override by None. Remove the 'dtype=None' part to correctly load data You then have no problem to save your data with the format you want. Fabrice PS : be aware that [data] is a 2D row array, that will end up inlined with command np.savetxt('13-7', [data], fmt='%15.9f', header='13-7') Remove the bracket for a one-per-line formatted output np.savetxt('13-7', data, fmt='%15.9f', header='13-7')
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion