Created
July 4, 2014 08:31
-
-
Save toruuetani/44887a9e6b474c3c2491 to your computer and use it in GitHub Desktop.
xlrd 使い方メモ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xlrd | |
book = xlrd.open_workbook(__name__, encoding_override="cp932") | |
sheet = book.sheet_by_name("シート名") | |
# 行数・列数取得 | |
rows = sheet.nrows | |
cols = sheet.ncols | |
# 値の取得 | |
sheet.rows(0) | |
# => [number:1.0, text:u'B1', number:1.3] | |
sheet.cols(1) | |
# => [empty:'', xldate:41824.0] | |
# 日付を datetime に | |
c = sheet.cell(1, 1) | |
# => xldate:41824.0 | |
xlrd.xldate_as_tuple(c.value, datemode=0) # datemode => 0: 1900-based, 1: 1904-based. | |
# => (2014, 7, 4, 0, 0, 0) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment