[Tutor] Writing back to same CSV in the next column
nymcity at yahoo.com
Tue Aug 11 02:23:50 CEST 2015
Wanted to write back to see if anyone had the chance to review my previous request.
ListOfIPAddresses = 
with open('top500ips.csv', 'rb') as f:
for line in f:
line = line.strip()
newFile = open('top500ips.csv', 'w')
for address in ListOfIPAddresses:
ResolvedAddresses = socket.gethostbyaddr(address)
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 <tutor at python.org> wrote:
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
Tutor maillist - Tutor at python.org
To unsubscribe or change subscription options:
More information about the Tutor