[Csv] Weird dialects?

Dave Cole djc at object-craft.com.au
Fri Jan 31 01:19:34 CET 2003


>>>>> "Andrew" == Andrew McNamara <andrewm at object-craft.com.au> writes:

Andrew> Something that occured to me last night - we might find that
Andrew> there are strange dialects that we can't easily parse with the
Andrew> C parser (without make it ugly). It occured to me that maybe
Andrew> the dialect should contain some sort of specification of the
Andrew> parser to use. But my feeling is that if it's too hard to
Andrew> parse with the C parser, it isn't a CSV file, and it should
Andrew> therefore be someone else's problem. Agreed?

Why not allow the parser factory function to be an optional argument
to the reader and writer factory functions?

    class csvreader:
        def __init__(self, fileobj, dialect='excel2000', parser=_csv.parser,
                     **options):
            :
            self.parser = parser(**parser_options)

This would allow pluggable parsers.

- Dave

-- 
http://www.object-craft.com.au



More information about the Csv mailing list