Carny Posted April 7, 2008 Share Posted April 7, 2008 Hi, i have a data email.txt containing infos in the format emailaddress:name. My Script reads all lines, splits them on the : and put them into two arrays. Then it splits the email to get the domain name the emailaddress is registered on and saves email:name in a new text data named *emaildomain*.txt. The list i start with has over 22.000 entrys, and it takes some time. But than the script gives me an error that it cant open "*emaildomain* .txt" (watch the space). First i thought this is because of the input data, but when i opened the email.txt with the notepad and searched for " " it doesnt found anything, so it must be an error in my script or something else. I already tried to replace all spaces in the temporarily data after reading from the source, but this doenst solve the problem. Heres the script: expandcollapse popup#include <String.au3> #include <array.au3> ;Verbessern: Evtl. Leerzeichen ersetzen! ; Emailliste laden $file = FileOpen("email.txt", 0) If $file = -1 Then MsgBox(0, "Fehler", "Die Datei email.txt konnte nicht geöffnet werden!") Exit EndIf ; Emails zählen $i = 1 While 1 $line = FileReadLine($file, $i) If @error = -1 Then ExitLoop $i+=1 Wend ; Email Array erstellen Dim $email[$i-1] Dim $name[$i-1] ; Email Array füllen $i2 = 1 Dim $linearray[2] While $i2 < $i $line = FileReadLine($file, $i2) If @error = -1 Then ExitLoop Endif $linearray = StringSplit($line, ":") If $linearray[0] = 2 Then $linearray[2] = StringReplace ($linearray[2], " ", "") $email[$i2-1] = $linearray[1] $name[$i2-1] = $linearray[2] Endif $i2+=1 Wend FileClose($file) ;_ArrayDisplay($email, "Emails") $i2 = 1 ; Emails splitten und abspeichern While $i2 < $i $linearray = StringSplit($email[$i2-1], "@") ;_ArrayDisplay($linearray, "Emails") If $linearray[0] = 2 Then $file = FileOpen("u_" & $linearray[2] & ".txt", 1) If $file = -1 Then MsgBox(0, "Fehler", "Die Datei u_" & $linearray[2] & ".txt konnte nicht geöffnet werden!") Exit EndIf FileWriteLine($file, $email[$i2-1] & ":" & $name[$i2-1]) FileClose($file) EndIf $i2+=1 Wend Maybe someone can take a look on this... Thank you in advance. Regards, Carny Link to comment Share on other sites More sharing options...
Developers Jos Posted April 7, 2008 Developers Share Posted April 7, 2008 You will have to give the input file containg a few test reocord that makes the script fail to be able to test. 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 More sharing options...
weaponx Posted April 7, 2008 Share Posted April 7, 2008 Instead of using FileReadLine() I would just do: #include <file.au3> Dim $myArray _FileReadToArray("email.txt", $myArray) For $X = 1 to $myArray[0] ... Next Link to comment Share on other sites More sharing options...
zorphnog Posted April 7, 2008 Share Posted April 7, 2008 ^What he said. Your current method iterates through the file twice, which = 2x longer execution. Also, try using: $linearray[2] = StringStripWS ($linearray[2], 8)oÝ÷ Ú)駡ö®¶sbb33c¶ÆæV'&³%ÒÒ7G&æu&WÆ6Rb33c¶ÆæV'&³%ÒÂgV÷C²gV÷C²ÂgV÷C²gV÷C² Link to comment Share on other sites More sharing options...
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