xlsx2csv icon indicating copy to clipboard operation
xlsx2csv copied to clipboard

lost one second when parse datetime

Open ohmycloud opened this issue 2 years ago • 3 comments

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

ohmycloud avatar Nov 10 '23 09:11 ohmycloud

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

image

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 image

weeinn avatar Dec 23 '23 05:12 weeinn