This week, I did some data manipulation to some excel files.
I found one tricky thing about excel.
I used python module called, xlrd to read the excel file into python.
The following is the python code from xlrd:
import xlrd
wb=xlrd.open_workbook("xl1.xlsx")
sh=wb.sheet_by_index(0)
And I found that sometimes when you count the number of the tab, if the tab is on the third
one by counting, but when you try sh=wb.sheet_by_index(3), it may fail. But if you try some other number for that tab, it may work.
And for the same file, if you save is as different formats, like excel 1997-2003 and excel 2010, when you read the file, the number of the tab, i.e. sheet_by_index which will work may be different for
the same tab. You sometimes need to try different numbers to find the right one.
One method to avoid this problem is to use sheet_by_name not sheet_by index, like the following.
But it will need more coding characters.
I wrote about the solutions to some problems I found from programming and data analytics. They may help you on your work. Thank you.
ezoic
Subscribe to:
Post Comments (Atom)
looking for a man
I am a mid aged woman. I live in southern california. I was born in 1980. I do not have any kid. no compliacted dating. I am looking for ...
-
I tried to commit script to bitbucket using sourcetree. I first cloned from bitbucket using SSH, and I got an error, "authentication ...
-
https://github.com/boto/boto3/issues/134 import boto3 import botocore client = boto3.client('s3') result = client.list_obje...
-
There are some fun tools on Mac/PC which can help you on your studies, life and research. 1. Evernote: https://evernote.com/ To downl...
No comments:
Post a Comment