xlsx2csv
xlsx2csv copied to clipboard
lost one second when parse datetime
save the ts column into test.xlsx
ts
2023-10-31 00:39:00
convert test.xlsx to test.csv:
xlsx2csv test.xlsx test.csv --dateformat '%Y-%m-%d %H:%M:%S'
the datetime 2023-10-31 00:39:00 is convert to 2023-10-31 00:39:00, with one second lost(run head test.csv):
ts
2023-10-31 00:38:59
I encountered the same problem
before convert, use pandas read excel
import pandas as pd
file_path = "C:\\Users\\acodingcat\\Desktop\\test.xlsx"
df = pd.read_excel(file_path)
current dataframe
after convert, use xlsx2csv convert xlsx to csv file
from xlsx2csv import Xlsx2csv
temp_path = "C:\\Users\\acodingcat\\Desktop\\test.csv"
Xlsx2csv(file_path,
dateformat="%Y-%m-%d %H:%M:%S",
skip_hidden_rows=False,
outputencoding="utf-8").convert(temp_path, sheetname="Sheet1")
df = pd.read_csv(temp_path)
after convert, some data lost one second accurary