BurntSushi / rust-csv

A CSV parser for Rust, with Serde support.
The Unlicense
1.69k stars 219 forks source link

Automatically add an index number to headers that contain duplicate fields. #353

Closed claudiofsr closed 7 months ago

claudiofsr commented 7 months ago

I have a CSV file with a header containing duplicate fields.

header: 'field_a;field_b;FooBar;field_c;FooBar;field_d'

I try to read a csv file and get the error:

Error: Error(Deserialize { pos: Some(Position { byte: 1017, line: 2, record: 1 }), err: DeserializeError { field: None, kind: Message("duplicate fieldFooBar") } })

Would it be possible to automatically add an index number to headers that contain duplicate fields?

header: 'field_a;field_b;FooBar;field_c;FooBar [2];field_d'

Or something like this.

BurntSushi commented 7 months ago

No, I don't think that's a good fit for this library. You can achieve what you want by modifying the headers first.

claudiofsr commented 7 months ago

OK thanks