I have a list like this:
name_CL = ['Lolo', 'Fadli', 'Jori', 'Andi', 'Budi', 'Dedi', 'Nori']
and i want to export the list to a CSV file using Flask-CSV using this code :
name_CL_to_CSV = []
for i in name_CL:
name_CL_to_CSV.append(i)
return send_csv([{'Name CL' : name_CL_to_CSV}],
"testing.csv", ['Name CL'])
But the result is like this
and then a try to modify the code a little bit like this:
name_CL_to_CSV = []
for i in name_CL:
name_CL_to_CSV.append(i)
return send_csv([{'Name CL' : name_CL_to_CSV}],
"testing.csv", ['Name CL'])
just modify the indentation in for loop .
and then i got this result:
So.. my question is how to get all of values in that list in one row on CSV file..?
What i want is the result like this:
Try this
name_CL_to_CSV = []
for i in name_CL:
name_CL_to_CSV.append({'Name CL' : i})
return send_csv(name_CL_to_CSV,
"testing.csv", ['Name CL'])
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.