Jump to content

New FAST line counter


ryeguy
 Share

Recommended Posts

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Read my reply to Jos. I linked to it there. I don't post code in this forum anymore.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I don't post code in this forum anymore.

Your sure about that!

In communications and information processing, encoding is the process by which information (thoughts) from a source (George) is converted into symbols (text) to be communicated (forum message)

:x Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

Having said that, we should probably look at the current UDF's for improvements using SRE.

Where could code be posted, instead of writing a bug report? I have made a suggestion for in the Example Forum, as the current _GetIP() is somewhat outdated.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • Developers

Trac is the place to submit bug reports and possible updates.

Just not sure how long it will take to get a reply as I am sure who is currently working on processing the UDF updates.

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

Link to comment
Share on other sites

OK, cool. Thanks for the reply :x

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Yes he is. You are looking at code as in encryption code, taking the definition out of context.

Bah, spoilsport. :x

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

I All.

All the functions which I was able to see, raise an enormous problem with a file of consequent size.

On my Windows 32 bit XP system, AutoIt cannot read files with a size greater than 183 145 241 octets.

If I try to do that, I'll get an error allocating memory. :P

For my personal use, I use a simple loop with FileReadLine a file handle and a counter, but this function is 4x slower than tylo's function, having said that, it works for files of any size. :x

I play a little time with tylo's function, and I noticed something very strange. :shifty:

if I use it with a large file > 179 639 503 octets, then if I run the function 1 or more times and then I use a MsgBox and again I use the tylo's function, then I have the error allocating memory (even if I wait a long time between the last launch).

If the size is smaller or equal to 179 639 503 octets, then I can do what I want. :nuke:

This is a sample code that produce the error :

; Test.txt file is a large file > 179 639 503 octets
; 179 639 600 octets is a good choice...

$Lines = _TFileCountLines("Test.txt")
MsgBox(0,"Just a MsgBox", "This message box seems to produce the error if file size if greater than 179 639 503 octets")
; To there, I havn't the error allocating memory

; Before this one finished, then I have the error allocating memory
$begin = TimerInit()
$Lines = _TFileCountLines("Test.txt")
MsgBox(0,"Time Difference for " & $Lines,TimerDiff($begin)/1000)
Exit


Func _TFileCountLines( $sFilePath )
   Local $N = FileGetSize($sFilePath) - 1
   If @error Or $N = -1 Then Return 0
   Return StringLen(StringAddCR(FileRead($sFilePath, $N))) - $N + 1
EndFunc

Best Regards.Thierry

Link to comment
Share on other sites

I used the other functions to count the lines on my standard ZIP codes file

I did not do any timed test I just checked the console for the time it took and here's what I get still.

Not watching a movie or anything and I did run the test more than once per function just to be fair (3)times.

Here's what I got from it:

Total Lines : 34417

$FLN = "Zip-Codes.txt"

$FLNcount = _File_CountLines($FLN)

Time: 0.553, Time: 0.542, Time: 0.548

$FLNcount = _FileCountLines($FLN)

Time: 0.331, Time: 0.336, Time: 0.324

$FLNcount = _File_CountLines2($FLN, 1)

Time: 0.546, Time: 0.542, Time: 0.550 (about the same results if you use 0 instead of 1 as an option)

Then again I have no empty lines so it wouldn't matter much.

Here's a sample of what's in each line: 01001,AGAWAM,MA,HAMPDEN,STANDARD

Not sure if what's in it effects the results even though there is not much of a difference I know which function I am still sticking to :x

I also like the FileReadLine it's great I don't even have to open a file to read the text.

I can just write something like $FileLine = FileReadLine($FLN, $LNum) and it gives me the text that is on the line # referred to by $LNum in the $FLN file name.

Link to comment
Share on other sites

All the functions which I was able to see, raise an enormous problem with a file of consequent size.

On my Windows 32 bit XP system, AutoIt cannot read files with a size greater than 183 145 241 octets.

If I try to do that, I'll get an error allocating memory. :P

For my personal use, I use a simple loop with FileReadLine a file handle and a counter, but this function is 4x slower than tylo's function, having said that, it works for files of any size. :x

; To there, I havn't the error allocating memory

; Before this one finished, then I have the error allocating memory

$begin = TimerInit()

$Lines = _TFileCountLines("Test.txt")

MsgBox(0,"Time Difference for " & $Lines,TimerDiff($begin)/1000)

Exit

Func _TFileCountLines( $sFilePath )

Local $N = FileGetSize($sFilePath) - 1

If @error Or $N = -1 Then Return 0

Return StringLen(StringAddCR(FileRead($sFilePath, $N))) - $N + 1

EndFunc

I use the console for my results (not into Message boxes :shifty: ), don't know about the size issue you're having, would have to run a test on a huge file to see if I get the same problem and experiment with it. My Zip code file, took a while parsing it and writing it to my needs, if I had to do it manually could have taken way longer hope I never run into a file that is that big. Edited by ALFJ
Link to comment
Share on other sites

In fact, I don't use really MsgBox, it's just that I have seen that on my tests.

I think it's not a normal behavior.

Perhaps it's an AutoIt bug?

I said that only for information, because I spent several hours to make tests to see the limits.

Best Regards.Thierry

Link to comment
Share on other sites

In fact, I don't use really MsgBox, it's just that I have seen that on my tests.

I think it's not a normal behavior.

Perhaps it's an AutoIt bug?

I said that only for information, because I spent several hours to make tests to see the limits.

I think it could be a size or type of text in the file issue, If it's due to the size then I guess you might have to use some sort of buffering to do parts at a time, which I don't know how to go about doing myself but someone else might know here and know if that's the case..

The way I see it.. is watching a HD movie from a website, they send information in buffer style, same thing when you are watching a movie locally, let's pretend it's a 100GB size movie.. of course if you open the whole movie with the movie app your PC will most likely crash, so I assume some sort of buffering is used with the movie viewers as well.. however you are trying to open a huge file with no buffer so it's failing, my opinion on it anyway.. whether it's right or not.. I am sure someone with more knowledge than me or someone with a similar issue might give us more pointers on this.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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