-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Can't read excel decimal seconds #5945
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
Comments
Here is some background from my answer to this question on SO: Pandas used However, For example, say you have an Excel file like this (Number is the same as time but without a format):
Then, if you read the data with the following program: import xlrd
workbook = xlrd.open_workbook('minutes.xls')
worksheet = workbook.sheet_by_name('Sheet1')
cell = worksheet.cell(2,0)
# Print the A2 cell value as a number.
print cell.value
# Print the seconds part of the A2 cell value.
print (cell.value * (24*60*60)) % 60
# Print the xldate_as_tuple output.
print xlrd.xldate_as_tuple(cell.value, workbook.datemode) You get the following output:
So, the decimal part of the seconds is read (51.2) but not returned by This is the documented behaviour of I'll submit a PR to |
I've submitted a PR to However, it may need an API change to fix properly in which case |
Submitted updated patch to xlrd for this: python-excel/xlrd/pull/78 |
look at the install script here on a 3.3 build. I believe xlsxwriter had a setup error (which didn't cause it to ultimately fail), - could be random too: https://travis-ci.org/jreback/pandas/jobs/17360736 |
It could be a random error or an error in an unrelated thread. Looking at the full log doesn't make it any clearer. XlsxWriter has it's own Travis CI build and I haven't seen any issues there. However, if you see another one in Pandas let me know. |
will do |
Before the patch in #6934: >>> import pandas as pd
>>> pd.read_excel('decimal_seconds_1900.xls', 'Sheet1')
Time
0 00:17:51
1 00:17:51
2 00:17:51
3 00:17:52
4 00:17:52
5 00:17:52 After the patch: >>> import pandas as pd
>>> pd.read_excel('decimal_seconds_1900.xls', 'Sheet1')
Time
0 00:17:51
1 00:17:51.200000
2 00:17:51.400000
3 00:17:51.600000
4 00:17:51.800000
5 00:17:52 |
closed by #6934 |
Fix to allow decimal seconds to be read from Excel dates and times into datetime objects. pandas-dev#5945.
related to #4332
I have an excel spread sheet (.xls) that contains a time column. The time is displayed in Excel as minutes:seconds.tenths of seconds. Such as "50:59.2" "50:59.4". The raw data contains hours:minutes:seconds.decimalseconds.
It seems that Pandas uses xldate_as_tuple() which apparently rounds all seconds, so the decimal part is dropped. So the above two data points both import as "50:59".
I suggest using a different conversion method, at least as an option. That way the data will not be dropped, as it is now.
I did also post this same issue to xlrd.
The text was updated successfully, but these errors were encountered: