My csv file(K2CsSb DOS135.csv) is very simple like:
-7.21E+00 1.34E-01
-7.16E+00 1.15E-01
-7.13E+00 0.00E+00
-7.10E+00 0.00E+00
-7.07E+00 0.00E+00
And I use genfromtxt to import this file like:
dosdata = genfromtxt('K2CsSb DOS135.csv',delimiter=',')
if I print(dosdata)
,it shows me:
[[-7.21 0.134]
[-7.16 0.115]
[-7.13 0. ]
...,
I used this 2D array data for interp1d in numpy.
Everything looks perfect. The csv file was edited in MS excel in WINDOWS.
Right now I am using MAC OS X and use mac MS excel editing this file only cut-paste, no change the data type. Then when I import this file as same as before and print. The show me error:
[-7.21 nan nan nan nan nan nan]
f = interp1d(data[:,0], data[:,1])
IndexError: too many indices for array
If I added dosdata = genfromtxt('K2CsSb DOS135.csv',delimiter=',',dtype=None)
Looks is a tur like:
(-7.21, b'1.30E-01\r-7.16E+00', b'1.20E-01\r-7.13E+00', b'0.00E+00\r-7.10E+00', b'0.00E+00\r-7.07E+00')
why happen that and how to fix it?