Carlos Aguni

Highly motivated self-taught IT analyst. Always learning and ready to explore new skills. An eternal apprentice.


Convert XLS to XLSX on the fly pandas

04 Aug 2020 » programming
from openpyxl import load_workbook
import xlrd
import io

df = pd.read_excel("file.xls")
output = io.BytesIO()
df.to_excel(output)
workbook = load_workbook(output)
s = workbook["Sheet1"]

#... work
for row in s.iter_rows():
    for cell in row:
        if cell.comment:
            print(cell.value, cell.comment.text)