From 95b4ae88b2ea73da1ce975e89152cb2208fe1c69 Mon Sep 17 00:00:00 2001 From: Jover Lee Date: Wed, 4 Dec 2024 14:29:20 -0800 Subject: [PATCH 1/2] data-formats: Add example Python snippets for TSV handling Prompted by @jameshadfield's request Snippets are simplified versions of TSV handling in Augur. --- src/reference/data-formats.rst | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/reference/data-formats.rst b/src/reference/data-formats.rst index 2db1329..f015566 100644 --- a/src/reference/data-formats.rst +++ b/src/reference/data-formats.rst @@ -30,6 +30,34 @@ When using `tsv-utils `__ | tsv-uniq -H -f strain \ | csvtk fix-quotes --tabs > output.tsv +If you are writing Python scripts that process TSV files, we recommend using the +`csv module `__ for file I/O. + +.. note:: + + Be sure to follow `csv module's recommendation `__ + to open files with ``newline=''``. + +Reading a TSV file: + +.. code-block:: Python + + with open(input_file, 'r', newline='') as handle: + reader = csv.reader(handle, delimiter='\t') + for row in reader: + ... + +Writing a TSV file: + +.. code-block:: Python + + with open(output_file, 'w', newline='') as output_handle: + tsv_writer = csv.writer(output_handle, delimiter='\t') + tsv_writer.writerow(header) + for record in records: + tsv_writer.writerow(record) + + See our internal `discussion on TSV standardization `__ for more details. JSON From 13bac655ab20452c7bf9b2b43b080c60a2b66af2 Mon Sep 17 00:00:00 2001 From: Jover Lee Date: Wed, 4 Dec 2024 15:45:17 -0800 Subject: [PATCH 2/2] Ignore CA Certificate link for linkcheck This has consistently returned 403 in GitHub Actions workflow, but does succeed when running linkcheck locally. Ignoring link for now and we can revisit later. --- src/conf.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/conf.py b/src/conf.py index b1c4734..4a79df5 100644 --- a/src/conf.py +++ b/src/conf.py @@ -103,6 +103,8 @@ # these URLs block the client the linkchecker uses r'^https://www\.pnas\.org/doi/10\.1073/pnas\.1507071112', r'^https://www\.ncbi\.nlm\.nih\.gov/books/NBK25501', + # This URL returns 403 in GH Actions, but succeeds locally. + r'^https://wiki\.mozilla\.org/CA/Included_Certificates', # we specifically use this as an example of a link that _won't_ work r'^https://nextstrain\.org/ncov/gisaid/21L/global/6m/2024-01-10', ]