Alexandre Leclerc escreveu:
I checked arround to see if there was a function to parse a valid CSV
string and return the result in a array?
procedure DecodeCSV(s: string; var a: array of string);
So a string like:
123, my name, "name, my", "just ""more"" text"
would return in an array:
[ '123' , 'my name' , 'name, my', 'just "more" text' ]
Take a look at this:
procedure CSVToStrings(const ACSVStr: String; AStrList: TStrings);
var
pos1,pos2:Integer;
begin
pos1:=1;
pos2:=pos(';',ACSVStr);
while pos1 < pos2 do
begin
AStrList.Add(Copy(ACSVStr,pos1,pos2-pos1));
pos1:=pos2+1;
pos2:=posex(';',ACSVStr,pos1);
end;
if pos1 < length(Trim(ACSVStr)) then
AStrList.Add(Copy(ACSVStr,pos1,succ(length(ACSVStr)-pos1)));
end;
Luiz
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives