this slowpoke moves

Read eMail in CSV File

procedure ReadCSV(liste: string);
var
  i, b, at, lang, anfang, ende: Integer;
  email, csv: TStringList;
  found1, found2, atf: Boolean;
begin
  csv := TStringList.Create;
  csv.LoadFromFile(liste);
  email        := TStringList.Create;
  email.Sorted := True;
  found1       := False;
  found2       := False;
  atf          := False;

  for i := csv.Count - 1 downto 0 do
  begin
    for b := Length(csv.Strings[i]) downto 1 do
    begin
      if csv.Strings[i][b] = '@' then
      begin
        at  := b;
        atf := True;
      end;
    end;

    if atf = True then
    begin
      for b := at downto 1 do
      begin
        if found1 = False then
        begin
          if b = 1 then
          begin
            anfang := b;
            found1 := True;
          end;
          if csv.Strings[i][b] = ';' then
          begin
            anfang := b + 1;
            found1 := True;
          end;
        end;
      end;
      found1 := False;


      for b := at to Length(csv.Strings[i]) do
      begin
        if csv.Strings[i][b] = ';' then
        begin
          if found2 = False then
          begin
            ende   := b;
            found2 := True;
          end;
        end;
      end;
      found2 := False;
      lang   := ende - anfang;
      email.Add(Copy(csv.Strings[i], anfang, lang));
      atf := False;
    end;
  end;
  Form1.ListBox1.Clear;
  Form1.listbox1.Items.addstrings(email);
  Form1.Label1.Caption := IntToStr(Form1.listbox1.Items.Count) + ' E-Mails gefunden!!';
  csv.Free;
  email.Free;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  ReadCSV('c:\temp.csv');
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate