利用xlrd处理Excel文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import  xlrd
 
workbook  =  xlrd.open_workbook(datafile)
 
sheet  =  workbook.sheet_by_index( 0 )
 
data  =  [[sheet.cell_value(row,col)  for  col  in  xrange (sheet.ncols)]  for  row  in  xrange (sheet.nrows)]
 
#sheet 的row index和 col index 都是从0开始的
 
coast  =  sheet.col_values( 1 ,start_rowx = 1 ,end_rowx = None ) # coast 是一个列表 行数范围[start,end)
 
#时间处理
 
exceltime  =  '1/1/13 1:00'
 
xlrd.xldate_as_tuple(exceltime, 0 ) #结果为 (2013,1,1,1,0,0)精确到秒
全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务