[英]Python CSV delimiter
im trying to write a csv file where all the values are in different cells.我正在尝试编写一个 csv 文件,其中所有值都在不同的单元格中。 my code right now:
我现在的代码:
fieldnames = ['name', 'deviceId', 'lastSync', 'type']
filename = "data.csv"
with open(filename, 'w', newline='', encoding='utf-8') as csvfile:
writer = csv.writer(csvfile, delimiter=',')
writer.writerow(fieldnames)
for data in dixtt:
print([data['name'], data['deviceId'], data['lastSync'], data['type']])
prefered output (the data output will be added once this problem is solved): ( https://i.stack.imgur.com/WtOq6.png ) preferred output(数据output将在解决此问题后添加):( https://i.stack.imgur.com/WtOq6.png )
what im getting: ( https://i.stack.imgur.com/6qUS6.png )我得到了什么:( https://i.stack.imgur.com/6qUS6.png )
i want all the data values in different cells (see picture examples).我想要不同单元格中的所有数据值(参见图片示例)。 ive tried changing the settings in excel through data -> text to columns and setting the delimiter there but that didnt work
我尝试通过数据更改 excel 中的设置 -> 文本到列并在那里设置分隔符,但这没有用
Your csv is fine, you just need to tell Excel to format the data properly.您的 csv 没问题,您只需告诉 Excel 正确格式化数据即可。
Follow this steps:按照以下步骤操作:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.