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

Bug: Uncaught exception "_csv.Error: field larger than field limit (131072)" #41

Open
corneliusroemer opened this issue Feb 3, 2025 · 0 comments

Comments

@corneliusroemer
Copy link

I'm diffing csvs that contain nucleotide sequences in some columns and they can get rather long, e.g. ~200k characters.

This causes csv-diff to crash with an uncaught exception:

csv-diff results/mpox_prod.invariant.seq.tsv results/mpox_staging.invariant.seq.tsv --key=submissionId --format=tsv
Traceback (most recent call last):
  File "/Users/corneliusromer/micromamba/envs/pp-integrity/bin/csv-diff", line 10, in <module>
    sys.exit(cli())
             ^^^^^
  File "/Users/corneliusromer/micromamba/envs/pp-integrity/lib/python3.12/site-packages/click/core.py", line 1161, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/micromamba/envs/pp-integrity/lib/python3.12/site-packages/click/core.py", line 1082, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/micromamba/envs/pp-integrity/lib/python3.12/site-packages/click/core.py", line 1443, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/micromamba/envs/pp-integrity/lib/python3.12/site-packages/click/core.py", line 788, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/corneliusromer/micromamba/envs/pp-integrity/lib/python3.12/site-packages/csv_diff/cli.py", line 73, in cli
    previous_data = load(previous)
                    ^^^^^^^^^^^^^^
  File "/Users/corneliusromer/micromamba/envs/pp-integrity/lib/python3.12/site-packages/csv_diff/cli.py", line 69, in load
    return load_csv(
           ^^^^^^^^^
  File "/Users/corneliusromer/micromamba/envs/pp-integrity/lib/python3.12/site-packages/csv_diff/__init__.py", line 19, in load_csv
    rows = [dict(zip(headings, line)) for line in fp]
                                                  ^^
_csv.Error: field larger than field limit (131072)

You could allow us to work with ~200k long columns by setting:

csv.field_size_limit(int(ct.c_ulong(-1).value // 2))

(from https://stackoverflow.com/a/54517228/7483211)

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

No branches or pull requests

1 participant