Hello friends, I want to format the log (text) file my email's server. The text file (named s1.txt) contains the following information, text file has about 3000 lines.
"hMailServer SpamProtection rejected RCPT (Sender: valeria0...@mikelsonconstruction.com, IP:187.62.63.218, Reason: Rejected by Spamhaus.)" "hMailServer SpamProtection rejected RCPT (Sender: veronika07...@etb.net.co, IP:190.25.189.74, Reason: Rejected by SpamCop.)" "hMailServer SpamProtection rejected RCPT (Sender: sofia...@pembroketownhouse.ie, IP:103.247.48.95, Reason: Rejected by Spamhaus.)" I want to select ip addresses in text file and I want to delete duplicated records. Finally I want to write this data into a new file. What do you suggest me? That codes returned me about 500 records and gives error ; Traceback (most recent call last): File "C:/Depo/Python/prj1/analiz.py", line 17, in <module> prnt(deger) File "C:/Depo/Python/prj1/analiz.py", line 7, in prnt iplist = list_line[1] IndexError: list index out of range) ------------------------------------------------------------------------------- My code is below; def prnt(L1): L1 = L1[:-1] list_line = L1.split(",") list0 = list_line[0] iplist = list_line[1] list2 = list_line[2] print(iplist) with open("s1.txt","r",) as file: for deger in file: prnt(deger) #with open("iplistesi.txt","w") as file2: # file2.write(i) Best Regards. Huseyin _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor