answer :
import datetime as dt
def write_csv(file_name, rows):
import csv
f = open(file_name, ‘w’)
writer = csv.writer(f)
for row in rows:
writer.writerow(row)
f.close()
Write your solution below
import csv
f = open(‘session_log.csv’)
reader = csv.reader(f)
rows = list(reader)[1:]
Clean and the new rows
clean_rows = [[‘user_id’, ‘session_start’, ‘session_end’]]
for row in rows:
user_id = row[0]
# Conver row data to integers
row = [int(x) for x in row]
start = dt.datetime(row[1], row[2], row[3], row[4], row[5])
end = dt.datetime(row[6], row[7], row[8], row[9], row[10])
session_start = start.strftime("%Y/%m/%d %H:%M")
session_end = end.strftime("%Y/%m/%d %H:%M")
clean_rows.append([user_id, session_start, session_end])
write_csv(‘session_log_clean.csv’, clean_rows)
Replace this line with your code
What I expected to happen:
may i know what does this time mean?
row = [int(x) for x in row]
What actually happened:
Replace this line with the output/error
<!--Enter other details below: -->
thanks!!!!