[Tutor] Extract from file
dkuhlman at rexx.com
Wed Jun 9 23:37:34 CEST 2010
On Tue, Jun 08, 2010 at 08:19:32PM -0700, Monte Milanuk wrote:
> On 6/8/10 5:44 PM, Manju wrote:
> >I need help with extracting information from file.
> >I have a file which is a comma delimited text file containing separate
> >line for each booking. Each line is composed of date, room number,
> >course number and course day.
> Course day??? Not sure what you meant by that, on top of the already
> mentioned 'date'...?
> >I need to extract only the room number which is entered at the prompt
> >and display course number, date and room number.
> >I have so far managed accept the entry from the prompt, to open the file
> >and display all the text
Monte gave you a good suggestion *if* you are sure that there is no
quoting and, especially, if you are sure that there are no commas
inside of quotes in your input data.
However, it seems that you are dealing with a CSV (comma separated
values) file. Python has a module for that. See:
That module might help you write safer code.
More information about the Tutor