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

Handle CSV files with "duplicate field" by reading the values in a vector #377

Open
szabgab opened this issue Dec 21, 2024 · 1 comment
Open

Comments

@szabgab
Copy link

szabgab commented Dec 21, 2024

I've just encountered the same problem as was described in #353. I was wondering about a different solution:

Given a header with duplicate fields:

name,other,name'

I wonder if the values could be deserialized into a vector. Assuming this is the definition of the struct:

#[derive(Deserialize, Debug)]
struct Message {
    name: Vec<String>,
    other: String,
}
@BurntSushi
Copy link
Owner

I think my answer remains the same. And I'm not even sure this is possible to do in the deserializer. And it should really be supported in serialization. And on top of that, this strikes me as ambiguous with the feature of capturing the "tail" of the record: https://docs.rs/csv/latest/csv/struct.Reader.html#rules

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

2 participants