Using python, how do I convert dates that are stored as m(m)/dd/yyyy in a csv file to yyyy-mm-dd for use in sqlite? -
i working csv file contains date field, dates formatted 1/8/1986 when need them read sqlite3 database in format 1986-8-1 or 1986-08-01. have seen lot of people talking issue, haven't understood answers being given. here how think work though: specific field, csv reader outputs converter method reparses date in format can used sqlite. don't think sqlite can used make conversion code, otherwise use instead. not sure how converter method work loadcsv method though.
if don't want install additional packages can following:
>>> datetime import date >>> d = '1/8/1986' >>> date(*reversed([int(x) x in d.split('/')])).strftime('%y-%m-%d') '1986-08-01'