[fpc-pascal] CSV via PCRE
graemeg.lists at gmail.com
Sat Nov 10 09:23:40 CET 2007
OK, while we are busy with show-and-tell... Then have a look at my
token library implementation.
* It's based on a Infinite State Machine.
* No external units required.
* Allows multiple separators (user selectable) between tokens.
* Allows for user selectable seperator characters.
* Does line number and position error reporting in case the CSV file
is not well formatted.
* Only parses the string once, so if you request multiple tokens, it
takes no performance it.
* I also think it is much easier to understand and extend than than
than single regex which looks more to me like your are cursing! ;-)
tokenizer := TTokens.Create(FieldSpecLine, ', ', '"', '"', '\',
lField := tokenizer.Token(2);
lAnotherField := tokenizer.Token(4);
- Graeme -
fpGUI - a cross-platform Free Pascal GUI toolkit
More information about the fpc-pascal