I am very new to python and trying to get time from csv file which has location id,vrm.,date,time on it and been inserted into table pay ans display but i need to insert time from csv file , where on table its prints as 00:00:00. how can I get timings from csv instead of entrydatetime
tmp = valid_date.split('/')
iso_date = "%s-%s-%s" % (tmp[2], tmp[1], tmp[0])
entryDatetime = "%s 00:00:00" % iso_date
expiryDatetime = "%s 23:59:59" % iso_date
sql_local = """INSERT INTO customer_1.pay_and_display
(plate, machine_id, ticket_datetime, expiry_datetime, ticket_name, ticket_price)
VALUES ("%s", "%s", "%s", "%s", "%s", "%s") """ % (vrm, location_id, entryDatetime, expiryDatetime, "WL", 0)
print sql_local
cursor.execute(sql_local)
curl = pycurl.Curl()
body = Body()
Ok, so there is time.strptime
to parse the string representing a date and the csv module in general to parse a csv file.
Edit: you can also use the strptime classmethod of datetime objects if you're dealing with dates.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.