The date in my data is stored in two different formats:
Dienstag 31. Dezember 2013 and 30. Juni 2007
I wrote scripts to extract Year/Month/Day from both formats and store them in a list:
for row in reader:
line_count = line_count + 1
if row[1] == "DATE":
pass
else:
date = row[1].encode('utf-8')
year = date.split('.')[1].split(" ")[2]
day = date.split(" ")[0]
day = day.replace('.', '')
month = date.split('.')[1].split(' ')[1]
for the first format
and
date = row[1].encode('utf-8')
year = date.split('.')[1].split(" ")[2]
day = date.split(" ")[0]
day = day.replace('.', '')
month = date.split('.')[1].split(' ')[1]
for the second format
However these date formats are randomly occurring throughout the dataset (row[1]). Is there a way to tell Python when it encounters one of the formats to use the respective script (like an if statement)?
Thanks.
