I am using np.savetxt for the first time, and I am trying to save two variables (a string and a float) in a file named "trial.csv" as follows:
import numpy as np
RT = 2.76197329736740
key_name = 'space'
print(RT,key_name)
# Save data in a CSV file named subj_data_file
np.savetxt("trial.csv", (RT,key_name), delimiter=',', header="RTs,Key_Name")
I got the following error:
TypeError: Mismatch between array dtype ('<U32') and format specifier ('%.18e')
I do not understand the meaning of both ('<U32') and ('%.18e'). As a matter of fact, I do not understand how to use fmt when I have floats, integers and strings ...
It is a simplified example, but concretely, I would have the RT values (floats) in one column "RTs" and the key_name (float) values in another column "Key_Name". I will create more columns later on, and although I provided one value for RT and one value for key_name in this example, there will be more RT values in the column "RTs" as well as key names in the column "Key_Name".