Skip to content

Commit

Permalink
curate: fix endless additional quotes
Browse files Browse the repository at this point in the history
Resolves <#1312>

We are expecting the CSV-like double quoting when there are internal
quotes. If the field value is already correctly double quoted, then
there should not be any additional quotes.
  • Loading branch information
joverlee521 committed Aug 1, 2024
1 parent 8b00fbd commit ad029f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion augur/io/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ def visible_worksheet(s: calamine.SheetMetadata) -> bool:
# change in a future Python version.
raise InvalidDelimiter from error

metadata_reader = csv.DictReader(handle, dialect=dialect)
# Only use the dialect delimiter and keep all other default format params
metadata_reader = csv.DictReader(handle, delimiter=dialect.delimiter)

columns, records = metadata_reader.fieldnames, iter(metadata_reader)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ Create NDJSON with internal quotes
> ~~

Test passthru with output to TSV.
This should not add any quotes around the field with internal quotes.
This should add double quotes around the internal quotes to match CSV-like quoting.

$ cat records.ndjson \
> | ${AUGUR} curate passthru \
> --output-metadata output-metadata.tsv

$ cat output-metadata.tsv
strain\tsubmitting_lab (esc)
sequence_A\tSRC VB "Vector", Molecular Biology of Genomes (esc)
sequence_A\t"SRC VB ""Vector"", Molecular Biology of Genomes" (esc)

Run the output TSV through augur curate passthru again.
The new output should still be identical to the first output.
The new output should still be identical to the first output because it is already double quoted.

$ ${AUGUR} curate passthru \
> --metadata output-metadata.tsv \
Expand Down

0 comments on commit ad029f6

Please sign in to comment.