Jump to content

hint to speed up FileRead function

Recommended Posts


i just want to give a hint how to speed up the fileread function drastically on large files (e.g. .dat).

instead of reading in the whole file you can create a loop reading in just a defined number of characters. the fileread function continues to read in characters beginning with the last character read before +1.

for example:

you have a large .dat file (several mbs) and you know that you don't need the first 162309 characters, but then you want to analyze the rest of the file in parts of 1024 characters (like splitting a database).

instead of reading in the whole file and then splitting it by stringmid() you can do it like that and save a lot of time:

    $a=FileRead($file,162309); the first 162309 characters to be ignored
    While 1
        $a=FileRead($file,1024); fileread in steps of 1024 characters
      ; do what you like to do
    Wend    ; next 1024 characters

in this way i was able to read in, split and rewrite a 5 mb data file within 3 seconds (before 20 minutes).

i noticed that this feature is not mentioned in help file.

and i am sorry if this hint was mentioned before.


Edited by jennico

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP:


Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...