Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSVReader does not handle quoted fields or tsv files #3635

Closed
zachlindsey opened this issue Mar 13, 2024 · 1 comment · Fixed by #3637
Closed

CSVReader does not handle quoted fields or tsv files #3635

zachlindsey opened this issue Mar 13, 2024 · 1 comment · Fixed by #3637

Comments

@zachlindsey
Copy link

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

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"]

Platform details:

{'commit_hash': 'c46a957bd',
 'commit_source': 'repository',
 'networkx_version': '3.2.1',
 'nibabel_version': '5.2.1',
 'nipype_version': '1.8.7.dev0',
 'numpy_version': '1.26.4',
 'pkg_path': '/home/USER/Desktop/nipype/nipype',
 'scipy_version': '1.12.0',
 'sys_executable': '/home/USER/Desktop/nipype/.venv/bin/python',
 'sys_platform': 'linux',
 'sys_version': '3.9.18 (main, Feb  1 2024, 11:48:51) \n[GCC 11.4.0]',
 'traits_version': '6.3.2'}

Execution environment

  • My python environment outside container
@zachlindsey
Copy link
Author

#3637

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant