469,306 Members | 1,628 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

read input file a line as a list in python

Hi, All:
I need to read a input file as soucre to process data. Ideally
if I can read a line from input file as a list (coloumn separate by
white space), reorganize field in a line. Does python has this kind of
command ?
for example, I read a line has:
"IP MAC Date..." as a line from input file, How can I only get MAC ?
Thanks,

Yong

Jul 18 '05 #1
1 1876
Yong Wang wrote:
Hi, All:
I need to read a input file as soucre to process data. Ideally
if I can read a line from input file as a list (coloumn separate by
white space), reorganize field in a line. Does python has this kind of
command ?
for example, I read a line has:
"IP MAC Date..." as a line from input file, How can I only get MAC ?
Thanks,

Yong


If I understood you correctly, this should do something like what you want:

for line in file("filename"):
ip, mac, date = line.split()
print mac

--
Ciao,
Matteo
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by Guyon More | last post: by
18 posts views Thread by jas | last post: by
1 post views Thread by Jose Reckoner | last post: by
1 post views Thread by NeoGregorian | last post: by
11 posts views Thread by jo3c | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.