0

I have the following string "1, 'John Doe', 'Micronesia, Federated States of'"

and the following model :

[DelimitedRecord(",")]
    public class Client
    {
        public int Id;
        public string Name;
        public string Country;
    }

When I use FileHelpers to parse it I get error because of the comma inside the country

pantonis
  • 5,601
  • 12
  • 58
  • 115
  • 1
    See https://stackoverflow.com/questions/42974657/filehelpers-quote-and-comma-in-fields and https://stackoverflow.com/questions/18529845/filehelper-escape-delimiter – Bernard Vander Beken Jun 28 '17 at 13:50
  • @BernardVanderBekn What is the purpose of this library if it cant handle it. I was trying to do the parsing manually but I switched to FileHelpers in order to avoid the struggle of writing the logic my self – pantonis Jun 28 '17 at 13:52
  • @pantonis You got the linked information, it explains your problem and possible solutions. If you don't like it move on to different implementations but it's not really worth to discuss the purpose of libraries just because your use case is not covered the way you want it to be (and such a discussion will not change the library anyway). – grek40 Jun 28 '17 at 14:38
  • @grek40 That is not my case. If you read above I have single quotes. the links contain solution for commas inside double quotes – pantonis Jun 28 '17 at 14:39
  • @pantonis so, is changing from `[FieldQuoted('"', QuoteMode.OptionalForBoth)]` to `[FieldQuoted('\'', QuoteMode.OptionalForBoth)]` and possably updating a few more places to hard a task for you or did you try and it's not working? – grek40 Jun 28 '17 at 14:43
  • I tried it and its not working – pantonis Jun 28 '17 at 14:46
  • Lets say you exchange your single quotes for double quotes, does the solution then work for you? (Because otherwise its not about the difference between single and double quotes) – grek40 Jun 28 '17 at 14:56
  • 3
    Found the problem. Had to add FieldTrim attribute to remove white spaces and the [FieldQuoted('\'', QuoteMode.OptionalForBoth)] works now – pantonis Jun 28 '17 at 15:11

0 Answers0