[Tutor] Writing back to same CSV in the next column
alan.gauld at btinternet.com
Wed Aug 12 03:16:30 CEST 2015
On 12/08/15 01:58, Nym City wrote:
> Please find the two requested files attached.
Since this is a text mailing list it's better to insert the files into
the email. Many servers will strip out attachments so they
can't be seen.
I've pasted them below.
10.0.0.2 remote host
10.0.0.3 No resolution availabe for 10.0.0.3
10.0.0.5 No resolution availabe for 10.0.0.5
So, basically you just want to append the name (or an error message)?
In pseudocode this would be
for line in in_file:
name = gethostaddr(line.strip())
out_file.write(line + '\t' + name)
out_file.write(line + '\t' + errrMsg)
delete in_file # or rename to .bak
rename out_file to in_file
Can you translate that to Python?
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:
More information about the Tutor