Hello,

I am reading Tony Gaddis "Teach Python" book and I am having trouble with an assignment that asks me to read from one file and then write to another file. The problem is that the file to read from has not been created yet. Can anyone help me understand this instruction a little better? I am averaging an A in the course and would like to keep it.

Below you will find the correspondence between the instructor and myself. ( Written Last to First)

Thanks,
Jim

Hello Ms. H,
I am still having trouble with using two text files. I cannot find any examples in Cha.7 text book or Code Examples. Would you please point me in the direction where I may find an example for this requirement?
Thank You,
Jim


Hello Ms. H,

The sequence of events that I am using now is to open a program that will gather gallons used from user, call a module to make calculations, use the info from the module to write info to a file named FinalProjectBill.txt.

After that is done, I open another program that will read the info written to FinalProjectBill.txt

I guess my confusion about the instructions is, if I should read from one file FinalProjectBill.txt first how does data get written to that file to begin with?

Thank you for the great help.

Jim


From Instructor:
You should read from one file (FinalProjectBill.txt) and then write to one (BranleyFinal.txt) with the results as we are learning file i/o (input/output) -

The screen is fine to display results also, but in the real world, often times all processing is done by reading and writing to files (actually databases that are beyond the scope of this class) and nothing ever displays on the screen.

You should not write to your input file.

Make sense?

From: Me
Sent: Tuesday, June 26, 2012 5:54 AM
To: Instructor
Subject: Two txt files

Hello Ms. H,

I started writing the program yesterday and by the evening I had

a WaterPayModule, an InputProgram, an OutputProgram and a text file named FinalProjectBill.txt. When I run the OutputProgram it gets input from the user, sends info to the WaterModule and receives some values that I use to write output to the hard drive file FinalProjectBill.txt. When I run the InputProgram it reads input from the hard drive text file FinalProjectBill.txt and prints it on the screen.

My question is why do I need two text files FinalProjectBill.txt and BranleyJamesFinal.txt ?

Thank you,
Jim
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to