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

Fix empty output in csv_vectors example #89

Merged
merged 1 commit into from
Apr 7, 2024

Conversation

neilyio
Copy link
Contributor

@neilyio neilyio commented Sep 18, 2023

I found that cargo run --example csv_vectors produced incorrect output:

Query { r: [], s: 12 }

Where, based on the example, I expected:

Query { r: [1, 2, 3], s: 12 }

I believe the csv::Reader::from_reader function expects data where each line is a record. However, in the example, all values are on a single line, so the CSV reader treats them as columns of a single record.

I adjusted the from_csv function's trait bounds to ensure that T can be both deserialized and converted from a string. I also revamped the CSV parsing using ReaderBuilder for a bit more flexibility.

This new implementation produces the expected output.

@samscott89
Copy link
Owner

Thank you!

@samscott89 samscott89 merged commit 9628c7e into samscott89:main Apr 7, 2024
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 this pull request may close these issues.

2 participants