Skip to content

Instantly share code, notes, and snippets.

@leovarmak
Created August 1, 2019 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leovarmak/7ebba2c7783610441aa7ad623d893aa5 to your computer and use it in GitHub Desktop.
Save leovarmak/7ebba2c7783610441aa7ad623d893aa5 to your computer and use it in GitHub Desktop.
import xlrd
from xlrd.sheet import ctype_text
# Give the location of the file
loc = ("/home/karthikvarma/python/img.xlsx")
# To open
wb = xlrd.open_workbook(loc)
sheet = wb.sheet_by_index(0)
temp = sheet.nrows
tempagain = sheet.ncols
# print(temp)
# print(tempagain)
j = 0
i = 0
for l in range(temp):
row = sheet.row(l+1)
for idx, cell_obj in enumerate(row):
cell_type_str = ctype_text.get(cell_obj.ctype, 'unknown type')
if(cell_type_str != 'empty'):
totallength = (idx - (len(row) - 1)) * (-1)
j = totallength
print('j: %s' % (j))
for l in range(tempagain):
gga = 1
col = sheet.col(l+1)
for idx, cell_obj in enumerate(col):
cell_type_str = ctype_text.get(cell_obj.ctype, 'unknown type')
if(cell_type_str != 'empty'):
if(gga == 1):
gga = 0
else:
totallength = idx -1
i = totallength -1
break
print('i: %s' % (i))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment