AGB  ·  Datenschutz  ·  Impressum  







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

mapped file

Ein Thema von mohfa · begonnen am 7. Apr 2008 · letzter Beitrag vom 8. Apr 2008
Antwort Antwort
mohfa

Registriert seit: 11. Feb 2007
97 Beiträge
 
Delphi 7 Enterprise
 
#1

mapped file

  Alt 7. Apr 2008, 22:56
Hello every one :

I have a Text File its size is about : 15 MB and i want to compare its lines with other text File . for the first time i used the TStringList to open the First File ( when its size was about 10 KB ) so i hade no problem and i used the TStringList like this :
Delphi-Quellcode:
--
Var
SL:TStringList;
S:String;
begin
//Load the text file (test.txt ) into the TStringList then use
For i:=0 to SL -1 do
if S=SL.Strings[i] then
Showmessage('yes :'+S+' is found in the file' );
...
...
end;
but when the File becoms more and more huge the TStringList takes forever to load the File's Lines and do the comparasion.
so what i think is to map the First File then do the comparasion and here is my question :
is there any function or procedure that loads the mapped file into the stringlist and do the comparasion very fast .


many thanks
  Mit Zitat antworten Zitat
Benutzerbild von lbccaleb
lbccaleb

Registriert seit: 25. Mai 2006
Ort: Rostock / Bremen
2.037 Beiträge
 
Delphi 7 Enterprise
 
#2

Re: mapped file

  Alt 7. Apr 2008, 23:22
whould you compare the both textfiles, or only some strings from the file??

when not, look at this:

compare 2 files

this methode uses memorystreams!!
i hope it can help you!
Martin
MFG Caleb
TheSmallOne (MediaPlayer)
Die Dinge werden berechenbar, wenn man die Natur einer Sache durchschaut hat (Blade)
  Mit Zitat antworten Zitat
mohfa

Registriert seit: 11. Feb 2007
97 Beiträge
 
Delphi 7 Enterprise
 
#3

Re: mapped file

  Alt 7. Apr 2008, 23:52
Zitat von lbccaleb:
whould you compare the both textfiles, or only some strings from the file??

when not, look at this:

compare 2 files

this methode uses memorystreams!!
i hope it can help you!
many thanks lbccaleb , but what i want is to compare line by line from the first huge text file with the 2nd text file .
  Mit Zitat antworten Zitat
Klaus01

Registriert seit: 30. Nov 2005
Ort: München
5.755 Beiträge
 
Delphi 10.4 Sydney
 
#4

Re: mapped file

  Alt 8. Apr 2008, 06:54
Good morning,

why not laoding the small file into a StringList
und running through the huge file line by line and
comparing the current line with the content of the StringList.

So the huge file has only be read by once and the
small file is located within the memory.

For reading the file line by line,
you may want to use the "old Pascal Style"
AssigneFile, readLn etc.
or the newer functions like
FileOpen, FileRead etc..

Have a nice day
Klaus
Klaus
  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 09:47 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