Dijit

Dumping Second column with python

Sep 8th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. import sys
  2. import xlrd
  3.  
  4. filename = sys.argv[1]
  5.  
  6. sheet = xlrd.open_workbook(filename).sheet_by_index(0)
  7. #sheet = book.sheet_by_index(0)
  8. csv_filename = filename.replace(".xlsx", ".csv")
  9.  
  10. csv_fh = open(csv_filename, 'w')
  11.  
  12. for rownum in range(2, sheet.nrows):
  13.     if isinstance(sheet.cell(rownum, 1).value, float):
  14.         print(int(sheet.cell_value(rownum,1)))
  15.         csv_fh.write(str(int(sheet.cell_value(rownum,1))) + '\n')
Add Comment
Please, Sign In to add comment