1

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

1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented May 20, 2022 at 15:16

1 Answer 1

1

OUTPUT AND CODE

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.