reading a line in file

Tim Williams listserver at tdw.net
Mon Aug 20 15:13:38 EDT 2007


On 20/08/07, Brian McCann <Brian.McCann at viziant.net> wrote:
>
>
>
> ________________________________
> From: tdwdotnet at gmail.com on behalf of Tim Williams
> Sent: Mon 8/20/2007 2:59 PM
> To: Brian McCann
> Cc: python-list at python.org
> Subject: Re: reading a line in file
>
>
>
>
> On 20/08/07, Brian McCann <Brian.McCann at viziant.net> wrote:
> >
> > Hi,
> >
> > I can read in the whole file build.number which has the following lines
> > how do I just capture the value of build.number and assign it to a
> variable
> > Thanks,
> > Brian
> >
> > contents of file build.number:
> > #Build Number for ANT. Do not edit!
> > #Mon Aug 20 04:04:51 EDT 2007
> > build.number=1
> > buildinfo.py
> > ##################################
> > #!/usr/bin/python
> > import string
> > import os
> > import sys
> > import time
> > import errno
> > import shutil
> > buildinfo = "build.number"
> > input = open(buildinfo, 'r')
> > for line in input:
> >         print line
> > #########################################
> >
> > command line when script is run
> > $ buildinfo.py
> > #Build Number for ANT. Do not edit!
> >
> > #Mon Aug 20 04:04:51 EDT 2007
> > build.number=1
> >
> >
>
> This is preferred nowadays
>
> for line in open(buildinfo):
>         print line
>
> Without a sample of the data, no-one can help you further.   If this
> is homework, you should say so, people will give you guidance :)
>



> Hi Tim,
> The sample data is in file build.number
>
> contents of file build.number:
>
>  #Build Number for ANT. Do not edit!
>  #Mon Aug 20 04:04:51 EDT 2007
> build.number=1
>
> Thanks,
> Brian
>
(bottom posting is preferred here :)  )

Brian,  can you expand on this a bit?    A single entry doesn't give
much to go on.   20-ish lines would be better.    Anyone looking at
this would need to see whether each entry was on its own line, whether
there are duplicates,  whether delimiters are always the same etc.



More information about the Python-list mailing list