Sorry i should have been more descriptive
The Script
room_num = raw_input("Enter your room number: ")
text_file = open("c:/roombookings.txt", "r")
whole_thing = text_file.readline()
if room_num in whole_thing:
print "Room number found here is the information:"
else :
print "Room number not found."
single_line = whole_thing.split('\n')
for single_line in text_file.readlines():
if room_num in single_line:
print single_line
fileObj = open("courseinfo.dat","w")
fileObj.write()
fileObj.close()
text_file.close()
roombookings.txt
Date, Room, Course, Stage
6-3-07,L1,MSW001,1
6-3-07,L2,MSP201,1
6-3-07,L3,WEB201,1
6-3-07,L4,WEB101,1
6-3-07,L5,WEB101,1
7-3-07,L1,MSW001,2
7-3-07,L2,MSP201,2
7-3-07,L3,WEB201,2
7-3-07,L4,WEB101,2
7-3-07,L5,WEB101,2
8-3-07,L1,WEB101,1
8-3-07,L2,MSP201,3
What i need to do is create a script that prompts the user for a room number(L1,L2 etc), then it should display each line relating to the room number the user entered.
I have managed to do this, however now i need to get it to save those results to a file called courseinfo.dat.
If i type in
fileObj.write(single_line)
for some reason it always saves the third line of roombookings.txt no matter what the user inputs

What am i doing wrong here haha