Question : read excel by row and output to txt
Answered by : good-grivet-ytx61bnwrfnr
import xlrd
import os.path
wb = xlrd.open_workbook(os.path.join('D:\TRB 2014 Data','SPS1 demo data.xlsx'))
wb.sheet_names()
sh = wb.sheet_by_index(0)
i = 1
with open("Output.txt", "a") as my_file: while sh.cell(i,11).value != 0: Load = sh.cell(i,11).value all_d = sh.col_values(i, 13, 19) DB1 = Load + " " + (" ".join(all_d)) my_file.write(DB1 + '\n') i += 1
Source : https://stackoverflow.com/questions/17977584/how-to-read-data-from-excel-and-write-it-to-text-file-line-by-line | Last Update : Fri, 12 Mar 21