Autor Beitrag
fritierte
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 58



BeitragVerfasst: Mi 29.09.04 20:58 
hi,

zzt programmiere ich ein windows-tool um in linux erstellte Protokolle auszuwerten

nun das problem:
linux-textdateien haben ja einen unix-zeilenumbruch, und ich kann damit die datei nicht einlesen, bzw. es wird eine einzige, 2 mb grosse zeile ausgelesen. wenn ich die protokolle mit einem browser herunterlade, wird der zeilenumbruch korrigiert abgeaendert, vermutlich weil der transfer im zeichenmodus erfolgt(oder so), wenn ich die dateien aber per urldownloadtofile von einem webserver herunterlade, behalten sie jedoch ihr zeilenumbruchformat :(

nun die frage:
gibt es schon vorgefertigte prozeduren die das format aendern koennen, oder vielleicht eine methode, die dateien mit windows-zeilenumbruch runterzuladen?
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Mi 29.09.04 21:22 
hi,

wenn du weißt, welche Steuerzeichen das im ASCII-Zeichensatz sind, kannst du sie ja nach dem "Suchen-Ersetzten"-Schema in #13#10-Zeilenumbrüche umwandeln...

AXMD
fritierte Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 58



BeitragVerfasst: Mi 29.09.04 22:11 
ja das problem is, dass das relativ lange dauern koennte, da die datei 16.000 und mehr zeilen haben kann, und das einfache laden in einen string ohne vorherige korrektur schon ca. 5 sekunden dauert
ausblenden Delphi-Quelltext
1:
2:
3:
assignfile(filepath,file);
reset(file);
readln(file,zeile);//oder die entsprechende prozedur die mir jetz net einfaellt


das war jetz aus meinem gedaechtnis, aber so in etwa lese ich die zeilen einzeln ein. das mit dem ersetzen weiss ich und kann ich auch selber machen, ich bin mir aber net sicher ob das schnell genug ist, um es einem user zuzumuten...sollt' ich vielleicht mal ausprobieren :roll:
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6393
Erhaltene Danke: 147

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 30.09.04 08:41 
Versuch es doch mal mit der TStrings-Komponente.
Mit LoadFromFile alles einlesen und dann im Speicher die Zeilenumbrüche ersetzen.
fritierte Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 58



BeitragVerfasst: Do 30.09.04 10:38 
ich lese die komplette datei mit readln in einen string, das klappt ach soweit, auch wenn es recht lansam ist. wenn ich jetzt
ausblenden Delphi-Quelltext
1:
stringreplace(f_string,#$A,#13#10,[rfReplaceAll]);					

aufrufe, dauert es entweder ewig, oder er haengt in einer Schleife fest :?:
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6393
Erhaltene Danke: 147

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 30.09.04 11:14 
Mit StringReplace habe ich noch keine Performance-Tests gemacht.
Hast Du schonmal kleinere Testdateien geprüft? Mit 10 Zeilen oder so?
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Do 30.09.04 11:29 
Schau dir mal die Funktion AdjustLineBreaks an..

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6393
Erhaltene Danke: 147

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 30.09.04 11:56 
Geile Funktion. Kannte ich noch nicht.
fritierte Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 58



BeitragVerfasst: Do 30.09.04 15:19 
ok thx, ein srtingreplace mit ca. 16.000 ersetzungen und einem 2mb-grossen string dauert uebrigends etwa 10 minuten auf einem 2400+ mobile athlon