Thread: Reading a file
View Single Post
Old 05-02-2006, 08:50 PM   #12 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
Works for me:
Code:
#!/usr/bin/python
import re             
returnline = []
f = open("List", "r") 
for line in f.readlines(): 
    returnline.append(re.compile(' ').sub(',', line[0:-1]))
for item in returnline:
    print item
Quote:
> ./test.py
------------------------------------------
12400,,JOHN,,MAN,,IT,
------------------------------------------
12500,,NICE,,JOHN,,LAW,
-------------------------------------------
12600,,PATRICK,,MAN,,CS,
------------------------------------------
__________________
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