import pandas as pd
from xlwt import Workbook
from datetime import datetime
df = pd.read_excel('yourexcell file.xlsx')
date=[]
for i in df.index:
start_date = df['date'][i] #date column name in excel file
start_time=df['time'][i] #time column name in excel file
date_time = datetime.strptime(start_date, "%d.%m.%Y")
comb=datetime.combine(date_time,start_time)
date.append(comb)
# dateandtime combined and ready.
wb = Workbook()
sheet = wb.add_sheet('Sheet 1')
for k in range(len(date)):
sheet.write(k,0,date[k])
wb.save('datetime_generated'+".CSV")
print("csv file saved.")
1条答案
按热度按时间kmpatx3s1#
我就这样解决了,而且成功了。有人可能对解决办法感到疑惑。
这里是:输出2018-05-27 00:00:00