ChiseledAbs
ChiseledAbs

Reputation: 2071

How to get csv.writer to remove the delimiter character inside of columns?

I'm trying to convert a json table to a csv file but the problem is that when a field contains the delimiter character it gets copied just the same and it can cause some interpretation problems later on. Is there an option in csv.writer to remove delimiter characters inside the fields if they are present ? Or at least brace the field with quotes I guess.

Upvotes: 0

Views: 1535

Answers (1)

user3657941
user3657941

Reputation:

Try passing

quoting=csv.QUOTE_ALL

to the csv.writer constructor. That will force the library to quote all fields.

Here is a link to the documentation for the quoting parameter and the link to the documentation for csv.QUOTE_ALL.

Upvotes: 2

Related Questions