xlsx2csv icon indicating copy to clipboard operation
xlsx2csv copied to clipboard

Times not converted correctly

Open mikerob-w4 opened this issue 4 years ago • 2 comments

I am getting strange output when trying to convert an Excel sheet containing times in format h:mm:ss (I am using timeformat='%H:%M:%S'). In the csv file most times appear correctly, such as 00:00:00 however others are appearing as numbers such as 1.0416999999999999E-2.

Excel and converted csv attached,

testxl.xlsx Values.csv

mikerob-w4 avatar May 26 '21 23:05 mikerob-w4

Just to provide a bit more information, converting times as numbers seems to happen for some cells if excel Format Cells is 'Time'. If Format Cells in Excel is Custom hh:mm:ss then the cells convert times to hh:mm:ss format in the csv.

Converting times as numbers only seems to happen to some times. 00:00:00 is converted as 00:00:00 while 00:15:00 is converted as a number.

mikerob-w4 avatar May 27 '21 14:05 mikerob-w4

This is still happening as of 0.8.3 for all Time values between 00:00:01 and 01:00:00.

I've worked around it in Python by reading the .xlsx into a pandas DataFrame and writing it back out again. (Why this works: the DataFrame doesn't have a Time dtype itself, and therefore converts any incoming Time cells into string.)

JamesW-NHS avatar Aug 30 '24 15:08 JamesW-NHS