By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,793 Members | 1,252 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,793 IT Pros & Developers. It's quick & easy.

read input file a line as a list in python

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.