How does Python read the number of rows and columns of Excel?

encountered a problem in the process of writing data to Excel. The written data is looped in by for, so it is written multiple times (written once per for cycle, with dozens of data at a time).
but when the data is written in the second for cycle, the data written at the first time will be overwritten, that is, the data written at the last time will be overwritten. The code snippet:

    workbook = xlwt.Workbook(encoding="utf-8")
    worksheet = workbook.add_sheet("sheet")
    biaotou = ["","","","","","","","","","","","",""]
    for i in range(0,len(biaotou)):
        worksheet.write(0,i,biaotou[i])
        workbook.save("%s.xlsx" % str(str(cons[0][0]) + "(" + str(cons[0][1]) + ")"))
    open_file = xlrd.open_workbook("%s.xlsx" % str(str(cons[0][0]) + "(" + str(cons[0][1]) + ")"))
    table = open_file.sheets()[0]
    rows_num = table.nrows
    for con in cons:
        rows_num += 1
        print(rows_num)
        for i in range(0,13):
            worksheet.write(rows_num,i,con[i])
            workbook.save("%s.xlsx" % str(str(cons[0][0]) + "(" + str(cons[0][1]) + ")"))

my solution is to get the number of rows in the current Excel, and then write the data from + 1 when writing, so it won"t be overwritten, but the line number is from 1 to 60 for each for loop, and the second time is from 1 to 60. The third time is 1 to 60. Read the line number every time you are reasonable. It should be cumulative.
or there are other good solutions, pandas.help me

.
Apr.29,2021

for simple data types, it is very convenient to use pandas

-sharp -*- coding: utf-8 -*-
import pandas as pd

df = pd.DataFrame([[1, 2, 3], [10, 20, 30]], columns=['a', 'b', 'c'])
df.to_excel('a.xlsx', 'demo sheet', index=False)
Menu