Guerrilla
Guerrilla

Reputation: 14866

Custom CSV Deserialization

I am using SS FromCsv<MyType>() to deserialize data from a third party service.

It works fine if data is exactly as defined but sometimes the third party service has issues with a record and instead of returning a number in a column it returns the string "unknown".

If the csv has any row with "unknown" instead of the expected number then deserializing the CSV fails.

Is there any way to make it skip these rows and just deserialize the correctly matching data?

Upvotes: 1

Views: 41

Answers (1)

mythz
mythz

Reputation: 143319

No, but you can do a string.Replace before deserializing it:

var rows = csv.Replace("unknown",-1).FromCsv<MyType>();

Upvotes: 2

Related Questions