简体   繁体   中英

Export data from python to csv

I want to do some calculations with python and export the data afterwards into a csv file. This works fine. But it writes everything into the same cell. So, I wanted to ask if it is possible to do the same just write every value in a cell. The way I export is the code below:

import csv

f = open('C:///Users///....csv', 'a', newline='')

row = [x, y,z]

writer = csv.writer(f)

writer.writerow(row)
f.close

Like this I get one cell with the value [x,y,z], but I would like to have each of x,y,z in a seperate cell.

import csv
row = [x, y,z]
with open("C:///Users///....csv", mode='a') as file:
    writer = csv.writer(file)
    writer.writerow(row)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM