Splitting string on commas when data can contain commas

前端 未结 3 834
小蘑菇
小蘑菇 2021-01-13 04:51

I have a CSV file (which I didn\'t design and I can\'t change now nor will I ever be able to change it) that contains lines like the following:

\"Surname, Firs

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-13 05:39

    I know there's a lot of people here who think character-by-character comparisons should never be used and will strongly disagree with me but I'm not convinced companies like Microsoft aren't the only ones who should be doing that sort of programming.

    Afterall, Split does character-by-character comparisons so why is it any less ugly when you call existing code that doesn't quite do exactly what you want?

    At any rate, my approach was to write my own code. And I've posted the code online at http://www.blackbeltcoder.com/Articles/files/reading-and-writing-csv-files-in-c.

提交回复
热议问题