Anyone know how I can import/export csv, txt files in a way similar to NET FileHelpers, but using Delphi, taking spaces and quotes into account and handling traditional CSV esca
My functions
function ParseCSVString(s: string; const delimiter: Char = ','; const enclosure: Char = '"'): TStrings;
var
i,len: Integer;
f: string;
inQuoted: Boolean;
begin
Result := TStringList.Create;
len := Length(s);
if len = 0 then Exit;
//Test,Test;"Test;Test";"Test""Test";;
f := '';
inQuoted := False;
i:=0;
while i < len do
begin
Inc(i);
if s[i] = enclosure then
begin
if inQuoted and (i 0) OR (Pos(enclosure,s) > 0) then
Result := enclosure+Result+enclosure;
end;