Similar to Meenakshi I am trying to append data to a file using numpy's savetxt function.
I have a .data file that I want to append more float32 data to.
responses = np.array(responses,np.float32)
responses = responses.reshape((responses.size,1))
# save as new training results
np.savetxt(sampleData,samples)
np.savetxt(responseData,responses)
# want the option to append to previously written results
I am able to append as binary with the following but I need to append in float32.
# append to old training results
with open(sampleData, 'ab+') as fs:
fs.write(samples)
with open(responseData, 'ab+') as fr:
fr.write(responses)
When I try
# append to old training results
with open(sampleData, 'a+') as fs:
fs.write(samples)
with open(responseData, 'a+') as fr:
fr.write(responses)
I get "TypeError: write() argument must be str, not numpy.ndarray"
What is the syntax/ extension I should be using to interact with this .data file type in python given the above?