In my current project I want to read some experimental data from a text file into Python using the following code:
import numpy as np
from matplotlib.dates i
I had to remove the quotes from the example text. (using python3.4)
ValueError: time data '"04.10.2012 08:15:27"' does not match format '%d.%m.%Y %H:%M:%S'
The workaround of unutbu work perfectly fine. Meanwhile it seems that the issue has been addressed. Using bytespdate2num()
instead of strpdate2num()
works for me.
Here is a workaround:
import numpy as np
import matplotlib.dates as mdates
def bytedate2num(fmt):
def converter(b):
return mdates.strpdate2num(fmt)(b.decode('ascii'))
return converter
date_converter = bytedate2num("%d.%m.%Y %H:%M:%S")
data = np.recfromtxt('example.txt',
comments='#',
delimiter=';',
names=('time', 't_ref', 't_s', 't_amb1', 't_amb2', 't_amb3'),
converters={'time': date_converter})