Jump to content

Recommended Posts

Posted (edited)

I have a script, where I need to read file line by line to a variable (80000 lines) takes it forever to do it. Is any way to make it faster?

Local $hFileOpen = FileOpen($SelectFile, $FO_READ)
$str = ""
  for $i = 1 to $num ; ~about 80000 lines
    Local $sFileRead = FileReadLine($hFileOpen, $i)
    $str = $str&$sFileRead
  next

Great thanx in advance!

Edited by topten
  • Developers
Posted

How much faster is this version for you?

Local $hFileOpen = FileOpen($SelectFile, $FO_READ)
$str = ""
for $i = 1 to $num ; ~about 80000 lines
    $str&= FileReadLine($hFileOpen)
next

Or else try this:

Local $str = FileRead($SelectFile)
$str = StringReplace($str,@crlf,"")

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

Great thanx  InunoTaishou,  Trong, Jos !

It works now much better :)

  On 5/7/2016 at 4:57 PM, Jos said:

How much faster is this version for you?

Local $hFileOpen = FileOpen($SelectFile, $FO_READ)
$str = ""
for $i = 1 to $num ; ~about 80000 lines
    $str&= FileReadLine($hFileOpen)
next

This one is say, 3-5 times faster than mine

 

 

Or else try this:

Local $str = FileRead($SelectFile)
$str = StringReplace($str,@crlf,"")

This one is about 20-30  times faster than mine

Expand  

 

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...