Perhaps this small sample code will help you along:
Code:
#!/usr/bin/python
import re # make regular expression available
list = []
f = open("Studentlist.txt", "r") # open file
lines = f.readlines() # make every line available
for line in lines: # loop through lines
if not re.match("^-", line): # if line dosn't start with '-'
list.append(line[0:-1])# Add to line array without '\n'
del list[0] # remove the first line "ID | etc "
for item in list:
print item
FOr reference, as teknomage noted, you might want to read up on the regular expression object in python, I find
The Regular expression howto usefull, from my code, what you need to do, is to find a way to split your lines in the list, so you'll end up with a list like:
Code:
[["12400", "JOHN MAN", "IT"],
["12500", "NICE JOHN", "LAW"],
["12600", "PATRICK MAN", "CS"]]
Right now the list in my code will end up containing
Code:
["12400 JOHN MAN IT",
"12500 NICE JOHN LAW",
"12600 PATRICK MAN CS"]
Which can be acomplished by using the regular expression methods on the list created by my small code portion.