I am new to Python (converting from Matlab) and I am having trouble reading a CSV file. Basically, I want create an array with the sequence of date/times in one variable and the corresponding data values (humidity measurements) in another variable (I want to skip the 2nd column). The file format is as follows:
07-24-14 01:00:01 PM,%RH,36.988
07-24-14 02:00:01 PM,%RH,40.832
...
I am using the numpy loadtxt function as follows (note: there are 21 headerlines in the file):
def datestr2num(s):
return datetime.strptime(s,'%m-%d-%y %I:%M:%S %p')
dates,vals = np.loadtxt('File.csv',usecols=(0,2),skiprows=21,converters={0:datestr2num},delimiter=',',unpack=True)
I am getting the following error:
TypeError: float() argument must be a string or a number
Thanks for your help in advance!