Marten Lehmann wrote:
) I need to parse a file line by line. It is basically a CSV file, not not
) completely.
)
) Imagine this content:
)
) "one","""two"",""three"""
)
) "" mean a replacement for one "
)
) Correctly parsed, I would get two values:
)
) one
) and
) "two","three"
)
) But I cannot split at , and I cannot split at ",", since both would lead
) to wrong parsing.
Obviously.
) So I have to lexically go through every character.
A strange conclusion. There are dozens of other ways to do it.
One example: split at , and then use some simple processing to determine
if an entry has an odd number of quotes and, if so, join it to the next
entry. Then postprocess the entries for the quotes.
Another example: Use one of the many existing CSV parsing module.
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT