Skip to content

Commit

Permalink
write_records_to_tsv: Stop quoting output TSV
Browse files Browse the repository at this point in the history
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 <#1312>

¹ <https://www.iana.org/assignments/media-types/text/tab-separated-values>
² <https://datatracker.ietf.org/doc/html/rfc4180#page-2>
  • Loading branch information
joverlee521 committed Jun 27, 2024
1 parent f0bd23e commit 915672e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion augur/io/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/io/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down

0 comments on commit 915672e

Please sign in to comment.