Review of Jesse Phillips's CSV Parser

Ary Manzana ary at esperanto.org.ar
Fri Oct 28 10:01:40 PDT 2011


On 10/28/11 1:14 PM, Jesse Phillips wrote:
> Ary Manzana Wrote:
>
>> I like the idea of reading a CSV into a struct, or treating all fields
>> as ints.
>>
>> But, in my experience, CSVs are never perfect... because humans fill
>> them, and humans aren't perfect or don't know "Oh, of course I must fill
>> only numbers in this column, otherwise programs will explode".
>>
>> So although it's a nice functionality, I think just returning everything
>> as strings is more than enough.
>
> If you are dealing with incorrect data you must deal with it. If you expect everything to be an int, and it isn't what are you going to do? I should check how easy it is to recover from an error.

You are right.

I see that you throw ConvException, because when some to!... fails it 
throws that. But you don't catch it. So you'd get something like "Can't 
convert 'hello' to an int", but you loose the information of which row 
and column caused the problem. So maybe catching it and throwing a more 
detailed exception...

Also, sometimes people fill out numbers with some comments, like "1 
apple", so maybe a less strict parsing for numbers might be good (as an 
option).

Just some comments :)


More information about the Digitalmars-d mailing list