Would like to parse IPv4 address from exit-addresses. Format of the file:
ExitNode 006C3FA7C3F6E3ACD13D0DD9B10C7DFA933C237B
Published 2012-06-12 05:04:03
LastStatus 2012-06-12 06:03:22
ExitAddress 220.0.231.71 2012-06-12 10:23:05
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
will give you
where
data.txtcontains the four lines you posted (I also ran it with the big file you linked to). Usingwithwill also “automagically” close your file for you when you are done, or an exception is encountered.This list comprehension will collect all of the data in a list for you once the data file has been opened:
or alternatively, if you don’t want to collect the whole list in memory at once, you could use a generator expression:
You’ll also have take care of closing the file yourself.