Thread: Reading a file
View Single Post
Old 05-04-2006, 11:20 AM   #20 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
hmm.... thats odd:
Code:
#!/usr/bin/python
import re             
returnline = []
f = open("List", "r") 
for line in f.readlines(): 
    returnline.append(re.compile('( |\t)').sub(',', line[0:-1]))
for item in returnline:
    print item
Quote:
> ./test.py
NUM,|FIRSTNAME|,SURNAME,|course,|
------------------------------------------
12400,ERIC,RONNEY,CS
------------------------------------------
12500,MICHAEL,OWEN,CS
------------------------------------------
12600,SCOT,MAN,CS
------------------------------------------
12700,GEOGE,YO,IT
------------------------------------------
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote