"Marc 'BlackJack' Rintsch" <[EMAIL PROTECTED]> wrote: > On Fri, 06 Jul 2007 08:34:55 +0200, Hendrik van Rooyen wrote: > > > You can even do it more simply - by writing a GetField() that > > scans for either the delimiter or end of line or end of file, and > > returns the "field" found, along with the delimiter that caused > > it to exit, and then writing a GetRecord() that repetitively calls > > the GetField and assembles the row record until the delimiter > > returned is either the end of line or the end of file, remembering > > that the returned field may be empty, and handling the cases based > > on the delimiter returned when it is. > > > > This also makes all the decisions based on the current character > > read, no lookahead as far as I can see. > > > > Also no state variables, no switch statements... > > > > Is this the method that you would call "Mickey Mouse"? > > Maybe, because you've left out all handling of quoting and escape > characters here. Consider this: > > erik,viking,"ham, spam and eggs","He said ""Ni!""","line one > line two" > > That's 5 elements: > > 1: eric > 2: viking > 3: ham, spam and eggs > 4: He said "Ni!" > 5: line one > line two
Also true - What can I say - I can only wriggle and mutter... I see that you escaped the quotes by doubling them up - What would the following parse to?: erik,viking,ham, spam and eggs,He said "Ni!",line one line two - Hendrik -- http://mail.python.org/mailman/listinfo/python-list