Skip to content Skip to sidebar Skip to footer

Valueerror: Time Data "['140209/1729']" Does Not Match Format '%y%m%d/%h%m'

This should be a very simple solution. I'm reading dates from a columnar array and getting an error due to a mismatch in format: ValueError: time data '['140209/1729']' does no

Solution 1:

As Ashwini Chaudhary commented, use formdata[0] instead of str(formdata):

>>> import datetime
>>> formdate = ['140209/1729']

>>> datetime.datetime.strptime(str(formdate), '%y%m%d/%H%M')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\_strptime.py", line 325, in _strptime
    (data_string, format))
ValueError: time data "['140209/1729']" does not match format '%y%m%d/%H%M'

>>> datetime.datetime.strptime(formdate[0], '%y%m%d/%H%M')
datetime.datetime(2014, 2, 9, 17, 29)

Post a Comment for "Valueerror: Time Data "['140209/1729']" Does Not Match Format '%y%m%d/%h%m'"