Урок на Делфи 67. Считать CSV.


задание на delphi. read CSV.

unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
ListBox1: TListBox;
ListBox2: TListBox;
ListBox3: TListBox;
ListBox4: TListBox;
ListBox5: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var i,k,e:integer;
s,d: string;
begin
Memo1.Clear;
Memo1.Lines.LoadFromFile('test.csv');
for e := 0 to 4 do
begin
for I := 0 to Memo1.Lines.Count-1 do
begin
s:=Memo1.Lines[i];
k:=Pos(';',s);
if k>0 then
begin
d:=Copy(s,1,k);
if i<=5 then
begin
if Components[i+1] is TListBox then
tListBox(Components[i+1]).Items.Add(d);
Delete(s,1,k);
Memo1.Lines.Delete(i);
Memo1.Lines.Insert(i,s);
end;
end;
end;
end;
end;
end.



Скачать