var
sl: TStringList;
s: string;
i: integer;
iStart: integer;
iEnd: integer;
col: integer;
begin
sl := TStringList.Create;
try
sl.LoadFromFile('C:\export_EMSC.csv');
StringGrid1.RowCount := sl.Count;
StringGrid1.FixedCols := 0;
StringGrid1.ColCount := 9;
for i := 0 to Pred(sl.Count) do
begin
s := sl[i] + ';';
col := 0;
iStart := 1;
iEnd := 1;
while (iEnd <= Length(s)) and (col < 9) do // col<9 to protect against bad file
begin
if s[iEnd] = ';' then
begin
StringGrid1.Cells[col,i] := Copy(s, iStart, iEnd-iStart);
iStart := iEnd+1;
Inc(col);
end;
Inc(iEnd);
end;
end;
finally
sl.Free;
end;
end;
|