gh-67230: add quoting rules to csv module (GH-29469)

Add two quoting styles for csv dialects.
They will help to work with certain databases in particular.

Automerge-Triggered-By: GH:merwok
This commit is contained in:
Skip Montanaro 2023-04-12 17:32:30 -05:00 committed by GitHub
parent 2b6e877767
commit 330a942b63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 3 deletions

View file

@ -187,6 +187,10 @@ class Test_Csv(unittest.TestCase):
quoting = csv.QUOTE_ALL)
self._write_test(['a\nb',1], '"a\nb","1"',
quoting = csv.QUOTE_ALL)
self._write_test(['a','',None,1], '"a","",,1',
quoting = csv.QUOTE_STRINGS)
self._write_test(['a','',None,1], '"a","",,"1"',
quoting = csv.QUOTE_NOTNULL)
def test_write_escape(self):
self._write_test(['a',1,'p,q'], 'a,1,"p,q"',