Reputation: 71
I am currently trying to write a list of scores called scores_int to a csv file. I want to make my csv file in this format:
https://gyazo.com/225685fc5e2d71426791ef55c92007d0
but it is currently being written in this format:
https://gyazo.com/8b1e374b6601f5a4025365975383c8c7
Here is my code for the write:
with open("srt_Scores.csv", "w") as sortfile: #Should write a new csv file every time containing the sorted scores
w = csv.writer(sortfile, delimiter = ",")
w.writerows([[v] for v in scores_int])
crashed = True
If anyone could help me it would be much appreciated, thanks.
Upvotes: 1
Views: 33
Reputation: 1315
Use "wb" instead of "w" because you need to open it as a binary file.
with open("srt_Scores.csv", "wb") as sortfile: #Should write a new csv file every time containing the sorted scores
w = csv.writer(sortfile, delimiter = ",")
w.writerows([[v] for v in scores_int])
crashed = True
Upvotes: 1