On 6/5/06, Alexandre Leclerc <[EMAIL PROTECTED]> wrote:
I checked arround to see if there was a function to parse a valid CSV
string and return the result in a array?

I have a FSM (Finite State Machine) that currently parses CSV and
extracts it to TStrings, but can very easily be adapted to any output
format (string array included). The CSV also doesn't need to be valid
- a exception will be raised appropriately if it finds a malformed CSV
structure.  For those not familiar with the State Design Pattern,
doing a quick Google Search should help.

Current Usage:
 TCSVParser.ExtractFields(const S: string; pFieldList: TStrings);

as I mentioned, it is very easy to adapt to get
 TCSVParser.ExtractFields(const S: string; var pArray: array of string);

I also have unit tests for the TCSVParser to validate all parts are
working correctly.
If anybody is interested, I could attach the code in a private email
or to this list.

Regards,
 Graeme.

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to