procedure CsvToGrid (Grid: TStringGrid);
Var
CsvData: TStringList;
RowData: String;
ARow, ACol: Integer;
CommaPos: Integer;
The begin
CsvData:=TStringList. Create;
Try
CsvData. LoadFromFile (' shuju \ test CSV);
Form1. Grid1. RowCount:=csvdata. Count + 1;
Form1. Edit1. Text:=inttostr (csvdata. Count);
For ARow:=0 to CsvData. Do the Count - 1
The begin
ACol:=0;
RowData:=CsvData. ValueFromIndex [ARow];
CommaPos:=Pos (', 'RowData);
While (CommaPos> 0) do
The begin
The Grid. Cells [ARow ACol + 1, + 1] :=Copy (RowData, 1, CommaPos - 1);
RowData:=Copy (RowData, CommaPos + 1, Length (RowData) - CommaPos);
CommaPos:=Pos (', 'RowData);
ACol:=ACol + 1;
end;
end;
The finally
CsvData. Free;
end;
end;