I
I
IvankoPo2017-09-03 01:00:18
Python
IvankoPo, 2017-09-03 01:00:18

How to parse this file?

there is a .txt file like this

202.152.3.26    g1172-outring-jktidsigr2.idola.net.id
1418434192
216.54.144.165	FAIL.NON-AUTHORITATIVE.in-addr.arpa
1418434192
58.159.227.250	58x159x227x250.ap58.ftth.ucom.ne.jp
1418434192
112.199.122.150   	150.122.199.112        clbrz.inet.eastern-tele.com
1418434192
58.215.67.134	FAIL.NON-AUTHORITATIVE.in-addr.arpa
1418434192
80.55.41.209	qp209.internetdsl.tpnet.pl
1418434192
88.60.20.38	host38-20-static.60-88-b.business.telecomitalia.it
1418434192
64.127.122.252  FAIL.NON-AUTHORITATIVE.in-addr.arpa

ip address and its dns
note there is a line where there are two ip and dns in general,
you need to create a dictionary where ip is the dns key - the value
will be added to the dictionary using the dict.setdefult("key", "value") method I
read the file line by line but I don’t know how to split a string into words although I know split, but how to check that ip is ip and not a set of numbers (I think to use reg. exp. but I can’t figure them out)
In general, give an example of a code how you would read a string and add it to the dictionary

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Moskus, 2017-09-03
@IvankoPo

https://gist.githubusercontent.com/mnordhoff/22131...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question