Why does csvwriter.writerow() put a comma after each character?

It expects a sequence (eg: a list or tuple) of strings. You’re giving it a single string. A string happens to be a sequence of strings too, but it’s a sequence of 1 character strings, which isn’t what you want.

If you just want one string per row you could do something like this:

csvwriter.writerow([JD])

This wraps JD (a string) with a list.

Leave a Comment