read input file a line as a list in python

Golawala, Moiz M (GE Infrastructure) Moiz.Golawala at ge.com
Tue Aug 17 20:47:10 CEST 2004


You could do this:

fileList = []
file = open("fileName.txt","r")

#read one line at a time into a list
fileList.append(file.readline())

Moiz Golawala
GE Infrastructure, Security
Software Engineer
Enterprise Solutions

T 561 994 5972
F 561 994 6572
E moiz.golawala at ge.com 
www.gesecurity.com

791 Park of Commerce Blvd., Suite 100
Boca Raton, FL, 33487, U.S.A.
GE Security, Inc.


-----Original Message-----
From: python-list-bounces+moiz.golawala=ge.com at python.org
[mailto:python-list-bounces+moiz.golawala=ge.com at python.org]On Behalf Of
Yong Wang
Sent: Tuesday, August 17, 2004 2:41 PM
To: python-list at python.org
Subject: 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
 
-- 
http://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list