Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import xlrd
- def OpenFile(path):
- book = xlrd.open_workbook(path)
- first_sheet = book.sheet_by_index(0)
- # Get the number of rows in this workbook
- rows = first_sheet.nrows
- # get the number of columns in this workbook
- cols = first_sheet.ncols
- print "There are %d rows in this workbook." % rows
- print "There are %d cols in this workbook." % cols
- for r in range(0,rows):
- cells = first_sheet.row_slice(rowx=r,start_colx=0,end_colx=cols)
- for c in cells:
- if c.ctype == xlrd.XL_CELL_DATE:
- date_value = xlrd.xldate_as_tuple(c.value,book.datemode)
- dt = str(date_value[1]) + "/" + str(date_value[2]) + "/" + str(date_value[0])
- print dt
- else:
- print c.value
- if __name__ == "__main__":
- path = "example1.xls"
- OpenFile(path)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement