I am new to programming in Python In a part of my code, a list is generated, which itself is a combination of other lists, such as the following output Like the following output, it is generated different times with different data
1
[['Charles Tao'], ['Sales representative'], ['Zhangtun No.21 Hua er shan village'], ['Tiexi District Pulandian City'], ['Dalian'], ['Liaoning']]
2
[['JENNY'], ['SALES MANAGER'], ['-'], ['-'], ['Ho Chi Minh'], ['-'], ['-'], ['VIETNAM'], ['vietfoods-ex']]
The data format continues in the same way, although some lists have different lengths
For example, I used the following two pieces of code, but I did not get the right output
for i in range(1):
for j in range(0, len(my_list)):
worksheet.write(i, j, my_list[j][i])
for i in range(0, len(my_list)):
worksheet.write(0, i, ','.join([str(elem) for elem in my_list[i]]))
I want to save this data in separate rows in an excel file like the attached image here "The points in the first column mean that the rows are continuous"
But every time the data is either not saved or is rewritten on the same data and is duplicate and I have no data in the new row
And I do not generate a new row in the Excel file
Thanks if anyone can help and guide me
CODE ITSELF -->
import xlsxwriter
with xlsxwriter.Workbook('NT.xlsx') as workbook:
sheet = workbook.add_worksheet()
row, col = 0, 0
for line in lines:
# only write nonempty lines
sheet.write_row(row, col, line)
col+=1