From 915672e9db021588349ede4e23f21003455eb705 Mon Sep 17 00:00:00 2001 From: Jover Lee Date: Wed, 26 Jun 2024 16:47:19 -0700 Subject: [PATCH] write_records_to_tsv: Stop quoting output TSV MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to TSV specs,¹ there are no restrictions on special characters other than tabs are not allowed in a field. This is different from the CSV specs,² which require double quotes around fields that contain special characters. Since this function only produces TSVs, follow the TSV specs and stop adding quotes. Resolves ¹ ² --- augur/io/metadata.py | 4 +++- tests/io/test_metadata.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/augur/io/metadata.py b/augur/io/metadata.py index 32747eceb..bcaef5b79 100644 --- a/augur/io/metadata.py +++ b/augur/io/metadata.py @@ -483,7 +483,9 @@ def write_records_to_tsv(records, output_file): output_columns, extrasaction='ignore', delimiter='\t', - lineterminator='\n' + lineterminator='\n', + quoting=csv.QUOTE_NONE, + quotechar=None, ) tsv_writer.writeheader() tsv_writer.writerow(first_record) diff --git a/tests/io/test_metadata.py b/tests/io/test_metadata.py index 301e841e2..45ec13f10 100644 --- a/tests/io/test_metadata.py +++ b/tests/io/test_metadata.py @@ -466,7 +466,7 @@ def output_records(): def expected_output_tsv(): return ( "strain\tcountry\tdate\n" - 'SEQ_A\t"""USA"""\t2020-10-01\n' + 'SEQ_A\t"USA"\t2020-10-01\n' "SEQ_T\tUSA\t2020-10-02\n" )