Getting JSON error: TypeError: Object of type time is not JSON serializable
How do I make it so that I can include a date column in a row using sheet.make_cell command successfully? without the JSON error (above)?
Running Python 3.7
Imports: import logging
import csv
import os
import pandas as pd
from datetime import date
- Read Excel file using Panda statement:
data = pd.read_excel('/home/pi/Documents/tscripts/Sample.xlsx',header = 0 ) df = pd.DataFrame(data)*
- Output from Panda read Excel file command above:
Excel file: [[Timestamp('2020-09-05 09:08:00'), datetime.time(9, 8, 39), ' College_of_the_Desert_to_PDC_HUB', 30, 14, 15, 16, 17, 18, 19, 'CCC-1494']]*
- For loop to build a row. The JSON error is at the sheet.make_cell("MyDate", element[1]) statement. Below is a copy/paste of the for loop. All other sheet.make_cell commands are successful and added as a row to my Smartsheet.
Row-column assignments in for loop where the JSON Error Occurs new_rows = []
for element in example:
row = Row(to_top=True,strong text
cells=[
sheet.make_cell("ccc_key_id", element[10]),
sheet.make_cell("CCD", element[2]),
sheet.make_cell("Max_In_Only", element[6]),
sheet.make_cell("Max_Out_Only", element[9]),
sheet.make_cell("avg_in_out_max", element[3]),
sheet.make_cell("MyDate", element[1]) **<<== Result's in a JSON error **
])
new_rows.append(row)
smartsheet.sheets.add_rows(sheet.id, new_rows)
- The MyDate column in Smartsheet can be defined as Date or Text-Number, still results with a JSON error.
Looked up on the Internet and couldn't find anything to help. Appreciate any help.