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
When parsing a file with 9 columns, the 8 required plus an additional FORMAT column, a confusing error is returned of the form "The line contains an invalid number of fields. Was 9 but expected 9".
What I Did
import vcfpy
path = '/path/to/file.vcf'
reader = vcfpy.Reader.from_path(path)
records = []
for record in reader:
# do work
Stack Trace:
File "<stdin>", line 1, in <module>
File "python3.12/site-packages/vcfpy/reader.py", line 175, in __next__
result = self.parser.parse_next_record()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "python3.12/site-packages/vcfpy/parser.py", line 804, in parse_next_record
return self.parse_line(self._read_next_line())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "python3.12/site-packages/vcfpy/parser.py", line 795, in parse_line
return self._record_parser.parse_line(line)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "python3.12/site-packages/vcfpy/parser.py", line 425, in parse_line
arr = self._split_line(line_str)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "python3.12/site-packages/vcfpy/parser.py", line 518, in _split_line
raise exceptions.InvalidRecordException(
vcfpy.exceptions.InvalidRecordException: The line contains an invalid number of fields. Was 9 but expected 9
The fix would be to update line 521 in vcfpy/parser.py to use self.expected_fields as opposed to 9 + len(self.samples.names), as this distinction is already handled when 9 + len(self.samples.names) is set at lines 399-402 and is used as the error criteria in parser.py line 513
The text was updated successfully, but these errors were encountered:
JarvisVon
changed the title
Confusing error message in "The line contains an invalid number of fields. Was 9 but expected 9"
Fix parse record error verbiage
Jun 24, 2024
Description
When parsing a file with 9 columns, the 8 required plus an additional
FORMAT
column, a confusing error is returned of the form "The line contains an invalid number of fields. Was 9 but expected 9".What I Did
The fix would be to update line 521 in vcfpy/parser.py to use
self.expected_fields
as opposed to9 + len(self.samples.names)
, as this distinction is already handled when9 + len(self.samples.names)
is set at lines 399-402 and is used as the error criteria in parser.py line 513The text was updated successfully, but these errors were encountered: