rust-csv icon indicating copy to clipboard operation
rust-csv copied to clipboard

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

Open szabgab opened this issue 11 months ago • 1 comments

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,
}

szabgab avatar Dec 21 '24 11:12 szabgab

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

BurntSushi avatar Dec 21 '24 12:12 BurntSushi