SHARE
TWEET

Untitled

a guest Oct 12th, 2017 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. import xlrd
  4.  
  5. workbook = xlrd.open_workbook("/home/dresio/lorena/lorenatest.xls")
  6. byroi_sheet = workbook.sheet_by_name('sort by ROI')
  7.  
  8. byroi_sheet.cell(0, 0).value
  9.  
  10. # find all rows with 'ROI Id' in the first column starting from row number 30
  11. row_id = 30
  12. while row_id < byroi_sheet.nrows:
  13.     row = byroi_sheet.row_values(row_id)
  14.     # prefix u for unicode
  15.     if row[0] == u"ROI Id":
  16.         # print 'Found ROI Id in row %d column 0' % row_id
  17.         # switch to the next row
  18.         row_id += 1
  19.         extracted_roi_id = int(byroi_sheet.row_values(row_id)[0])
  20.         #print 'The ROID Id is %d' % extracted_roi_id
  21.         print 'ROID', extracted_roi_id
  22.  
  23.         # ignore the colum title
  24.         row_id += 2
  25.         row = byroi_sheet.row_values(row_id)
  26.  
  27.         # extract the columns
  28.         while row[0] != u'--------':
  29.             # print the two columns 6 and 33
  30.             print float(row[6 - 1]), float(row[33 - 1])
  31.             row_id += 1
  32.             if not row_id < byroi_sheet.nrows:
  33.                 break
  34.             row = byroi_sheet.row_values(row_id)
  35.  
  36.     row_id += 1
RAW Paste Data
Top