我有这个excel文件:
declare
StartDateTime date := timestamp '2017-01-01 00:00:00';
EndDateTime date := timestamp '2017-12-31 23:59:59';
begin
-- do something here
dbms_output.put_line(StartDateTime);
dbms_output.put_line(EndDateTime);
end;
我使用以下python脚本将其转换为csv文件:
import random
randomIndex = random.randint(0, len(diceList) - 1)
randomDice = diceList[randomIndex]
这是输出:
DB client_id client_name Joining Date
13542 0021I156 Loyiso Dwala 2013-04-05
13077 0043E03 Attwell Fayo 2013-04-06
13155 0023G025 David Mbhele 2013-04-07
如您所见,client_id列已将import xlrd
import csv
from datetime import datetime
with xlrd.open_workbook('myexcelfile.xlsm') as wb:
data = wb.sheet_by_index(2)
column_date = 5
with open('mycsvfile.csv', 'wb') as f:
c = csv.writer(f)
c.writerow(data.row_values(6))
for r in range(7,data.nrows):
year, month, day, hour, minute, sec = xlrd.xldate_as_tuple(int(data.row_values(r)[column_date]), wb.datemode) #unpack all values here, not just year, month, day
py_date = datetime(year, month, day)
py_date_2 = py_date.date()
c.writerow(data.row_values(r)[:5]+[py_date_2] + data.row_values(r)[6:])
转换为DB client_id client_name Joining Date
13542 0021I156 Loyiso Dwala 2013-04-05
13077 4.30E+38 Attwell Fayo 2013-04-06 <--
13155 0023G025 David Mbhele 2013-04-07
。
通过研究这一点,我意识到我必须对格式化做一些事情,即:
0043E03
但是如何在使用csv writer时专门为client_id列执行此操作?