Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lost one second when parse datetime #269

Open
ohmycloud opened this issue Nov 10, 2023 · 1 comment
Open

lost one second when parse datetime #269

ohmycloud opened this issue Nov 10, 2023 · 1 comment

Comments

@ohmycloud
Copy link

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
@weeinn
Copy link

weeinn commented Dec 23, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants