randomal
randomal

Reputation: 6592

savetxt - save array with integers and floats

I need to append an array made of integer and floats to a txt file. I wrote a script (below) following the standard procedure, but the numbers are all saved as floats... Do you have any suggestion on how to fix this? Also, do you know how to define how many decimals to use? Thanks!

with open(output, 'a') as f:
np.savetxt(f, A.reshape((1,8)), delimiter='\t', fmt='%i %i %i %f %f %f %f %f')
f.close()

Upvotes: 1

Views: 656

Answers (1)

XapaJIaMnu
XapaJIaMnu

Reputation: 1502

Your save format is set to floats (%f).

Change it to some of the integer ones listed in the reference

for example %d %i

Upvotes: 1

Related Questions