Jan-14-2019, 04:49 PM
Thanks a lot snippsat,I am an absolute beginner, only working in Python in a week.
However, I changed the file to xlsm and now I am using xlrd
import xlrd
file_location='O:\xxx\xxxx\xxx Python.xlsm'
workbook = xlrd.open_workbook(file_location)
sheet = workbook.sheet_by_index(1)
sheet.cell_value(0,0)
sheet.nrows
sheet.ncols
for col in range(sheet.ncols):
print (sheet.cell_value(3, col))
It's reading the data without triggering the macro, but now I need to write the data to a csv file and struggling to understand how using the for. Is there a way to give a range to set a loop in print (sheet.cell_value(3, col)) and to use a variable instead of print?
Many Thanks
However, I changed the file to xlsm and now I am using xlrd
import xlrd
file_location='O:\xxx\xxxx\xxx Python.xlsm'
workbook = xlrd.open_workbook(file_location)
sheet = workbook.sheet_by_index(1)
sheet.cell_value(0,0)
sheet.nrows
sheet.ncols
for col in range(sheet.ncols):
print (sheet.cell_value(3, col))
It's reading the data without triggering the macro, but now I need to write the data to a csv file and struggling to understand how using the for. Is there a way to give a range to set a loop in print (sheet.cell_value(3, col)) and to use a variable instead of print?
Many Thanks