Hello,
Wanted to write back to see if anyone had the chance to review my previous
request.
import socket
import csv
ListOfIPAddresses = []
with open('top500ips.csv', 'rb') as f:
for line in f:
line = line.strip()
ListOfIPAddresses.append(line)
f.close()
# print(ListOfIPAddresses)
newFile = open('top500ips.csv', 'w')
for address in ListOfIPAddresses:
try:
ResolvedAddresses = socket.gethostbyaddr(address)[0]
except socket.herror as e:
print("No resolution available for %s: %s" % (address, e))
newFile.write.(ResolvedAddresses + "\n")Thank you.
On Sunday, August 2, 2015 7:47 PM, Nym City via Tutor <[email protected]>
wrote:
Hello,
Below is my program where I am reading a list of IPs from a CSV file and
running it through the socket module. The result of the computation is stored
in a variable named ResolvedAddresses. However, there are some that are not
resolved and for those there is an exception.
The task that I am trying to complete now is taking the output of the
ResolvedAddresses and the content of the exception and write is back out to the
same CSV file where the data is originally imported from. Ideally, I would like
this new information to be in the column B and match with column A.
Thank you in advance. And please let me know if what I am trying to accomplish
is not clear and I'll try to explain it better.
Here is the code: https://bpaste.net/show/01a412f72fa1
Thank you.
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor