Greenseed Posted January 14, 2005 Posted January 14, 2005 this is a script to split word text file in multiple 10meg files everything work fine except he is not fast and he is slow down each time the loop recycle maybe im not realy good in programation please check as bit many thx. i attached my au3 file and a dictionary.au3 who is a rar files. expandcollapse popup; World List Splitter ; Created 2005-janvier-13 By Greenseed ; version 0.1 ;MsgBox(4096,"",$_path) ;************************************************************************************** ;*****************************************Debut**************************************** ;************************************************************************************** ;declare option AutoItSetOption ( "trayiconDebug",1 ) ;-------Declare Variable--------- $_var1 = 1 $_checkdupe = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" $_bytesread = 0 $_timerdif = 1000 $_filetowrite = "" $_linetowrite = "" $_readline = "" $_line = 1 ; Selection du fichier $_wordfile = FileOpenDialog ( "Choisis Le Fichier De Mots A Spliter", "c:\", "All (*.*)" , 1 + 2) ; calcule le path $_pos = StringInStr ( $_wordfile, "\" , 0, -1) $_len = StringLen ( $_wordfile ) $_todelete = $_len - $_pos + 1 ; path ou lire et ecrire le fichier $_path = StringTrimRight ( $_wordfile, $_todelete ) ; ouvre le fichier a lire FileOpen ( $_wordfile, 0 ) $_bytestoread = filegetsize ( $_wordfile ) ProgressOn ( "Progression", "", "", 0, 0, 2 + 16) $_timer = TimerInit() ;ouvre le fichier a ecrire $_filetowrite = $_path & "\wordsplit_" & $_var1 & ".txt" Fileopen ( $_filetowrite, 1 ) _read() func _read() ;lit le fichier jusqu'a fin While 1 $_readline = FileReadLine ( $_wordfile, $_line ) while $_readline = $_checkdupe $_Checkdupe = "aaaaaaaaaaaaaaaaaaaaaaaaaa" $_line = $_line + 1 $_readline = FileReadLine ( $_wordfile, $_line ) wend ;check la grosseur du fichier a ecrite si ye plus grand que 10meg il en ouvre un autre while Filegetsize ( $_filetowrite ) > 10240000 FileClose ( $_filetowrite ) $_var1 = $_var1 + 1 $_filetowrite = $_path & "\wordsplit_" & $_var1 & ".txt" Fileopen ( $_filetowrite, 1 ) wend ;Ecrite la ligne au fichier $_filetowrite $_checkdupe = $_readline $_bytesread = $_bytesread + Stringlen ( $_readline ) FileWriteLine ( $_filetowrite, $_readline ) $_line = $_line + 1 _progress() if @error = -1 then exitloop Wend ;ferme les fichiers et quitte fileclose( $_wordfile ) fileclose( $_filetowrite ) exit endfunc func _progress() if Timerdiff($_timer) > $_timerdif then $_timerdif = $_timerdif + 1000 $_pourcent = Int($_bytesread * 100 / $_bytestoread) $_speed = round( $_bytesread * 1000 / timerdiff ( $_timer ) / 1024, 2); Kbytes/seconde $_eta = round ( round ( $_bytestoread - $_bytesread, 0 ) / 1024 / $_speed,2 ); seconde If $_speed > 1024 Then $_speed = Round($_speed / 1024, 2) & " Mb/Sec" Else $_speed = $_speed & " Kb/Sec" EndIf If $_eta > 0 Then If $_eta > 60 Then $_eta = Round($_eta / 60, 0) & " Min" Else $_eta = $_eta & " Sec" EndIf Else $_eta = "" EndIf ProgressSet($_pourcent, "Etat: " & $_eta & " @ " & $_speed) endif endfunc ;************************************************************************************** ;*******************************************End**************************************** ;**************************************************************************************wlspliter.au3dictionary.au3 GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You.
Administrators Jon Posted January 14, 2005 Administrators Posted January 14, 2005 A quick scan shows you are using the FilReadLine function with a line number parameter. If you read line 10 the file is rewound and then 1,2,3....10 are read. So for big files doing it like this gets slower and slower.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now