You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
generate_samplesheet.py emits malformed CSV when FASTQ paths contain commas #1296
At commit 95bdacc803aa5cfdb10f35e5b9fb2d4b11100133, generate_samplesheet.py reports success but writes an invalid RNA-seq CSV when a FASTQ path contains a comma.
Steps to reproduce
Place a valid paired FASTQ set at reads,run/sample_R1_001.fastq.gz and reads,run/sample_R2_001.fastq.gz (the directory name contains a comma).
The generation command exits 0 and reports one samplesheet row. The CSV header has four fields (sample,fastq_1,fastq_2,strandedness), but the data row parses as six fields because both FASTQ paths contain a comma. The validation command exits 1, reporting missing FASTQ paths and an invalid strandedness value.
Expected behavior
Each FASTQ path remains one quoted CSV field. The data row has four fields and the generated samplesheet passes --validate.
Cause and verification
_write_samplesheet writes rows with ','.join(values) instead of a CSV writer. I reproduced this on Windows with Python 3.14.8 and valid gzip FASTQ records. Using the same input, the unmodified script produced 4 header fields / 6 data fields and failed its own validator. A local change using csv.writer produced 4 / 4 fields, passed validation, and passed a focused regression test.
_write_samplesheet now writes rows with csv.writer instead of ','.join, keeping \n line endings, so output for ordinary paths is unchanged. Tested with the repro above: the comma path now gives 4 header fields and 4 data fields and passes --validate, and a plain path gives the same file as before.
External PRs to this repo are auto-closed, so I'm linking it here in case a maintainer wants to pick it up.
I looked into this and the cause is in _write_samplesheet: rows are built with ','.join(...), so any field containing a comma is split into extra columns and the file then fails the script's own --validate.
A minimal fix is to write the header and rows with csv.writer, keeping \n line endings so output for ordinary paths stays byte-for-byte the same:
importcsv# moved to module levelwithopen(output_path, 'w', newline='') asf:
writer=csv.writer(f, lineterminator='\n')
writer.writerow(active_columns)
forrowinrows:
writer.writerow([str(row.get(col, '')) forcolinactive_columns])
I opened #1305 with this change before realizing the repo only accepts contributions from Anthropic team members, so it was auto-closed. The full commit is here in case it's useful: CryptGodSon@88fa205
Activity
CryptGodSon commentedon Oct 10, 2026
I have a fix for this on my fork: CryptGodSon@88fa205
_write_samplesheetnow writes rows withcsv.writerinstead of','.join, keeping\nline endings, so output for ordinary paths is unchanged. Tested with the repro above: the comma path now gives 4 header fields and 4 data fields and passes--validate, and a plain path gives the same file as before.External PRs to this repo are auto-closed, so I'm linking it here in case a maintainer wants to pick it up.
CryptGodSon commentedon Oct 11, 2026
I looked into this and the cause is in
_write_samplesheet: rows are built with','.join(...), so any field containing a comma is split into extra columns and the file then fails the script's own--validate.A minimal fix is to write the header and rows with
csv.writer, keeping\nline endings so output for ordinary paths stays byte-for-byte the same:I opened #1305 with this change before realizing the repo only accepts contributions from Anthropic team members, so it was auto-closed. The full commit is here in case it's useful: CryptGodSon@88fa205