AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

txt datei filtern

Ein Thema von Christian18 · begonnen am 26. Apr 2004 · letzter Beitrag vom 26. Apr 2004
Antwort Antwort
Christian18

Registriert seit: 9. Dez 2003
Ort: Hamburg
1.279 Beiträge
 
#1

txt datei filtern

  Alt 26. Apr 2004, 20:47
Hallo,

ich habe eine log datei und wollte diese auswerten. es ist eine textdatei und die wollte ich in ein Grid einlesen. wie mache ich das???

217.184.141.217 - - [22/Apr/2004:17:09:55 +0200] "GET / HTTP/1.1" 200 636 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"

so sehen die einträge aus.

ich wollte sie so haben

feld 1 im Grid: 217.184.141.217

feld 2 im Grid: 22/Apr/2004:17:09:55 +0200

feld 3 im Grid: "GET / HTTP/1.1" 200 636 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
  Mit Zitat antworten Zitat
XeRo

Registriert seit: 23. Okt 2003
Ort: Warth
461 Beiträge
 
Delphi 7 Enterprise
 
#2

Re: txt datei filtern

  Alt 26. Apr 2004, 21:05
Also wenn die zeilen immer gleich lang sind, dann würd ich erstmal ne zeile mittels string einlesen und dann mittels copy aufteilen...
  Mit Zitat antworten Zitat
Benutzerbild von SirThornberry
SirThornberry
(Moderator)

Registriert seit: 23. Sep 2003
Ort: Bockwen
12.235 Beiträge
 
Delphi 2006 Professional
 
#3

Re: txt datei filtern

  Alt 26. Apr 2004, 21:08
am besten mit "copy" und "posex"
Delphi-Quellcode:
var LStartpos, LEndepos: Integer;
    LPart1, LPart2, LPart3, Lzeile: String;
begin
  Lzeile := '217.184.141.217 - - [22/Apr/2004:17:09:55 +0200] "GET / HTTP/1.1" 200 636 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"';

  LStartpos := 1;
  LEndepos := PosEx(' - - [', LZeile);
  LPart1 := copy(LZeile, LStartpos, LEndepos - 1);

  LStartpos := posEx(' - - [', LZeile, LEndepos) + 6;
  LEndepos := posEx('] "', LZeile, LStartpos);
  LPart2 := copy(LZeile, LStartpos, LEndepos - LStartpos);

  LStartpos := LEndepos + 3;
  LEndepos := length(LZeile);
  LPart3 := copy(LZeile, LStartpos, LEndepos - LStartpos);
Jens
Mit Source ist es wie mit Kunst - Hauptsache der Künstler versteht's
  Mit Zitat antworten Zitat
XeRo

Registriert seit: 23. Okt 2003
Ort: Warth
461 Beiträge
 
Delphi 7 Enterprise
 
#4

Re: txt datei filtern

  Alt 26. Apr 2004, 21:25
Na toll, ich plag mich da ab, und versuch auf eine lösung zu kommen, dabei hat sie SirThornberry bereits gebracht.

meine sah so aus...

Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
const
   aha='217.184.141.217 - - [22/Apr/2004:17:09:55 +0200] "GET / HTTP/1.1" 200 636 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"';

var
 a,b:Integer;
 c,d:Boolean;

begin
For a:=1 to Length(aha) do
 begin
  if (aha[a]=' ')and(c=False) then
   begin
    StringGrid1.Cells[0,0]:=Copy(aha,0,a);
    c:=True;
   end;
  if aha[a]='[then b:=a;
  if aha[a]=']then StringGrid1.Cells[1,0]:=Copy(aha,b,a);
  if (aha[a]='"')and(d=False) then
   begin
    StringGrid1.Cells[2,0]:=Copy(aha,a,Length(aha));
    d:=True;
   end;
 end;
end;

Einen Versuch wars wert...
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:50 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz