I am trying to load a data file that is two columns of data, separated by a comma using: Data = np.loadtxt('real3kHz.dat')
, where real3kHz.dat
is the name of the file with the following data:
4998.29641,-0.00003
4997.33205,-0.00005
4996.36768,-0.00007
4995.40332,-0.00008
4994.43895,-0.00008
4993.47459,-0.00008
4992.51023,-0.00006
4991.54586,-0.00006
4990.5815,-0.00005
4989.61714,-0.00006
....
However, I keep getting the following error:
ValueError: could not convert string to float: '4998.29641,-0.00003'
I presumed that I successfully changed the cvs file into a .dat file (by saving it as a .dat
file in notepad) before loading it into python. Can I get some help understanding where I am going wrong?
Thank you in advance
question from:
https://stackoverflow.com/questions/65837457/how-can-i-load-a-dat-file-that-is-comma-separated-in-python 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…