When the data report is generated, we usually use the program to generate the CSV. Some of them need to be noted.
Log_file = open ('Delay.%s.csv'% S_end,'W') Log_file.write ('\XEF\XBB\XBF'+'current handler, current step ID, title (event name), occurrence time, event type, risk level, processing time limit, department name, extension days \ n') Status={0:'Draft', 10:'in Process', 80:'in Review', 90:'End' } forDinchdelay_flows: forFinchdelay_flows[d]['flows']: DL= Datetime.datetime.strptime (f.data['Deadline'],'%y-%m-%d%h:%m:%s') DX= Now-DL Log_file.write ('%s,%s, "=hyperlink (" "http://flow.dddd.com/detail?caseid=%s" "," ""%s "") ",%s,%s,%s,%s,%s,%d\n'%(f.data['Current_handler'], Status[ff.status]ifFf.statusinchStatusElseFf.status, f.case_id, f.data['Alertname'], f.data['Applytime'], F.bug_type, f.data['Risklevel'], f.data['Deadline'], f.department, Dx.days,) log_file.close ()
First prevent Excel in Windows above open CSV is garbled, we need to write at the head of the file
' \XEF\XBB\XBF '
Then if you need to insert a hyperlink
"=hyperlink (" "http://flow.dddd.com/detail?caseid=%s" "," ""%s "") "
Where the entire field needs to be "", or the middle of them, the comma will separate the fields, double quotation marks in the middle of double quotes to Double "" ".
CSV-Operation Comparison