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

Failure to parse content when last line is a comment. #363

Open
Comattin opened this issue Apr 24, 2024 · 1 comment
Open

Failure to parse content when last line is a comment. #363

Comattin opened this issue Apr 24, 2024 · 1 comment
Labels

Comments

@Comattin
Copy link

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.

@BurntSushi BurntSushi added the bug label Apr 24, 2024
@BurntSushi
Copy link
Owner

Nice find.

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

No branches or pull requests

2 participants