Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 6th, 2009, 1:20 AM   #1
jabbadabba
Newbie
 
Join Date: Jul 2009
Posts: 1
Rep Power: 0 jabbadabba is on a distinguished road
How to save results from script to a txt file

Here is my code atm

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()

The user types in a roomnumber and the script displays the information regarding the roomnumber only. What i need to do is have the script save the same data to a seperate file. I can get the script to create the file but not the results from the search.

I am 85% sure that where i have the ????????? is where the answer lies... however i am not smart enough to know exactly what i am doing wrong

What should i be doing that i have forgotten?
jabbadabba is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need a Perl script to parse a file out and loop it richsark Perl 6 Feb 20th, 2009 7:36 AM
printing a txt file issue badbasser98 C++ 2 Jun 22nd, 2007 12:31 PM
How to save all search engine results urls in a text file abojan ASP 0 Dec 27th, 2006 9:33 AM
Windows batch file script chronosoft Other Scripting Languages 6 Oct 10th, 2006 10:43 AM
script to obtain jpgs and compress them and save them to an output file Jimineep Bash / Shell Scripting 2 May 18th, 2005 10:16 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:49 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC