2021年4月6日星期二

How to correctly write (H:M) time format into a newline without commas after each number into an existing CSV using python?

I have an existing csv file "meetingschedule.csv" and into its new column in 'Time' row , I have to add the current time in (%H:%M) format after the 4 columns of given times. But with my code , I am always getting the Time with commas in between:(

Like the Time --> 18:39 would be written as "1,8,:,3,9" as in the following meetingschedule.csv file -

Time,Meeting ID,Passcode  06:47, 999 9722 2425,  16:59, 999 9722 2425,  20:02, 999 9722 2425,  18:08, 999 9722 2425,  1,8,:,3,9  

What should I do to fix this issue!? Also , If possible , also provide me the way to insert two commas after writing the Current_Time .

My Code is Given below--

import datetime , csv  from datetime import datetime    timestr = datetime.now().strftime("%H:%M")  with open("meetingschedule.csv","a") as csvFile:      Fileout = csv.writer(csvFile)      Fileout.writerow(timestr)  

For example, I require the output as --

Time,Meeting ID,Passcode  06:47, 999 9722 2425,  16:59, 999 9722 2425,  20:02, 999 9722 2425,  18:08, 999 9722 2425,  18:39,,  

Thanks For the Help !

https://stackoverflow.com/questions/66979040/how-to-correctly-write-hm-time-format-into-a-newline-without-commas-after-eac April 07, 2021 at 11:06AM

没有评论:

发表评论