i have a sample CSV given as follows:
Name,Birthdate,Age,Address,Zone
ABC,3-10-2016 11:00:00AM,21,XYZ Street 21, zone
BCD,3-11-2016 15:54:00PM,22,WXY Street 21/A, S zone
CDW,4-11-2015 21:09:00PM,22,ZYX Street 21Avenue, North Zone
i have used the following code to obtain the weekday from a given date in the data:
import csv
from datetime import datetime
with open(filename, 'rb') as infile:
reader = csv.DictReader(infile)
for row in reader:
birthdate = row['Birthdate'] # keys are named in the first row of your CSV
birthdate = datetime.strptime(birthdate, '%m-%d-%Y %H:%M:%S%p')
print birthdate.strftime('%A')
The output was:
Thursday
Friday
Saturday
i want to append this output into the same CSV with a new column name as weekday .
NOTE: the above code and data are all sampled and original data is way different.