You can use datetime.
from datetime import *
dateStr = '31-Jul-18'
date = datetime.strptime(dateStr, '%d-%b-%y')
newDateStr = date.strftime('%Y-%m-%d')
print(newDateStr)
The value of the Date
column cut and imported in commas can be considered as dateStr
.
Convert this to a datetime
object using datetime.strptime().
Refer to https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior for the %d-%b-%y
format used at this time.
This converted datetime
object can be converted to a string via datetime.strftime().
%Y-%m-%d
is the desired format yyyy-mm-dd
.
You can save the time newDateStr
converted to a string in CSV.
915 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
612 GDB gets version error when attempting to debug with the Presense SDK (IDE)
618 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.