I want to add functionality to the CSVReader so it can handle tsv files. While checking that out, I noticed that we're just splitting on ,, which is not ideal.
Actual behavior
Parsing CSV files with fields that contain quoted text with ',' characters does not work correctly. TSV files are not supported.
Expected behavior
Quoted fields should be correctly parsed if they contain the delimiter.
How to replicate the behavior
Run the script below.
Script/Workflow details
from nipype.interfaces import utility
reader = utility.CSVReader()
lines = ["foo,\"hello,world\",300.1\n"]
with open("testcsv.csv", "w") as fid:
fid.writelines(lines)
fid.flush()
reader.inputs.in_file = "testcsv.csv"
out = reader.run()
assert out.outputs.column_1 == ["hello, world"]
Summary
I want to add functionality to the CSVReader so it can handle tsv files. While checking that out, I noticed that we're just splitting on
,
, which is not ideal.Actual behavior
Parsing CSV files with fields that contain quoted text with ',' characters does not work correctly. TSV files are not supported.
Expected behavior
Quoted fields should be correctly parsed if they contain the delimiter.
How to replicate the behavior
Run the script below.
Script/Workflow details
Platform details:
Execution environment