BurntSushi / BurntSushi/rust-csv

Failure to parse content when last line is a comment.

Open
#363 1 comment 2 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
2k
Forks
257
PR merge metrics
No merged PRs in 30d

Description

#### What version of the `csv` crate are you using?

csv 1.3.0

#### Briefly describe the question, bug or feature request.

When the last line of the csv data is a comment, deserialization results in a CSV error stating that the found record does not have the appropriate number of fields when the expectation is that the line should be ignored all together since it starts with the comment character. Example error message: CSV error: record 2 (line: 5, byte: 70): found record with 1 fields, but the previous record has 3 fields

#### Include a complete program demonstrating a problem.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=62901b8c4ce6c97e87a2dc73cfcc267a

#### What is the observed behavior of the code above?

Standard Output
Beginning test case: Content ends with a record.
Test case finished.
Beginning test case: Content ends with a newline.
Test case finished.
Beginning test case: Content ends with an #Comment then newline.
Test case finished.
Beginning test case: Content ends with an #Comment.
CSV error: record 2 (line: 5, byte: 70): found record with 1 fields, but the previous record has 3 fields

#### What is the expected or desired behavior of the code above?
Standard output should be:
Beginning test case: Content ends with a record.
Test case finished.
Beginning test case: Content ends with a newline.
Test case finished.
Beginning test case: Content ends with an #Comment then newline.
Test case finished.
Beginning test case: Content ends with an #Comment.
Test case finished.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.