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

Headers with Serde Deserialization #3

Open
teburd opened this issue Jun 24, 2016 · 2 comments
Open

Headers with Serde Deserialization #3

teburd opened this issue Jun 24, 2016 · 2 comments

Comments

@teburd
Copy link

teburd commented Jun 24, 2016

I created a similiar ticket for rust-csv, it would be nice to have a csv deserializer that can take advantage of csv headers to match up with struct members.

@tafia
Copy link
Owner

tafia commented Jul 7, 2016

Sorry for the late answer.

First serde is not implemented (only rustc_serialize), because serde was slow and was breaking too much for my taste (when I looked into it).

Anyway, I'm not certain I understand your issue.
Does it mean storing the headers to know the field names and then ignoring the columns that are not affected to a field?
Can you provide a csv and what you're expecting exactly?

@teburd
Copy link
Author

teburd commented Aug 15, 2016

@tafia Sorry for the delayed reply, an example scenario might be... from GTFS data

stop_id,stop_name,trip_id
'0','Jackson','5'
'1','Monroe','5'
'2','Washington','5'

Which I'd then like to deserialize into a struct using (serde would be nice) like...

struct Stop {
   stop_id: String,
   stop_name: String,
   trip_id: String
}

fn deserialize_stops(...) -> Vec<Stop> {
   // some code here to deserialize each csv row directly to a Stop
}

Notably the ordering of columns shouldn't matter in determining which struct fields to use for each csv column, only the csv column header should be used to match in this case.

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

No branches or pull requests

2 participants