[英]How to write a Nested lists into excel new rows using python?
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我是编程新手,在Python我的一段代码中,生成了一个列表,它本身就是其他列表的组合,比如下面的output 和下面的output一样,是不同的时间生成不同的数据
1 [['Charles Tao'], ['Sales representative'], ['Zhangtun No.21 Hua er shan village'], ['Tiexi District Pulandian City'], ['Dalian'], ['Liaoning']]
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']]
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比如我用了下面两段代码,都没有得到正确的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"我想将此数据保存在 excel 文件中的单独行中,就像此处的附件“第一列中的点意味着行是连续的”
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而且我没有在 Excel 文件中生成新行
Thanks if anyone can help and guide me谢谢,如果有人可以帮助和指导我
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.