Re: Newby Question for reading a file

2009-02-19 Thread Steve Holden
alex23 wrote: > On Feb 20, 5:38 am, Peter Otten <__pete...@web.de> wrote: >> Yes you can get portions of the line by slicing: >> >> for line in open("infile"): >> if line[8:18] != line[18:28]: >> print line, > > You can also name the slices, which makes the code more clear (IMO): >

Re: Newby Question for reading a file

2009-02-19 Thread alex23
On Feb 20, 5:38 am, Peter Otten <__pete...@web.de> wrote: > Yes you can get portions of the line by slicing: > > for line in open("infile"): >     if line[8:18] != line[18:28]: >             print line, You can also name the slices, which makes the code more clear (IMO): endda = slice(8,18) begda

Re: Newby Question for reading a file

2009-02-19 Thread steven.oldner
On Feb 19, 1:44 pm, Curt Hash wrote: > On Thu, Feb 19, 2009 at 12:07 PM, steven.oldner > wrote: > > > On Feb 19, 12:40 pm, Mike Driscoll wrote: > > > On Feb 19, 12:32 pm, "steven.oldner" wrote: > > > > > Simple question but I haven't found an answer.  I program in ABAP, and > > > > in ABAP you

Re: Newby Question for reading a file

2009-02-19 Thread Peter Otten
steven.oldner wrote: > On Feb 19, 12:40 pm, Mike Driscoll wrote: >> On Feb 19, 12:32 pm, "steven.oldner" wrote: >> >> > Simple question but I haven't found an answer.  I program in ABAP, and >> > in ABAP you define the data structure of the file and move the file >> > line into the structure, an

Re: Newby Question for reading a file

2009-02-19 Thread Curt Hash
On Thu, Feb 19, 2009 at 12:07 PM, steven.oldner wrote: > > On Feb 19, 12:40 pm, Mike Driscoll wrote: > > On Feb 19, 12:32 pm, "steven.oldner" wrote: > > > > > Simple question but I haven't found an answer. I program in ABAP, and > > > in ABAP you define the data structure of the file and move t

Re: Newby Question for reading a file

2009-02-19 Thread steven.oldner
On Feb 19, 12:40 pm, Mike Driscoll wrote: > On Feb 19, 12:32 pm, "steven.oldner" wrote: > > > Simple question but I haven't found an answer.  I program in ABAP, and > > in ABAP you define the data structure of the file and move the file > > line into the structure, and then do something to the fi

Re: Newby Question for reading a file

2009-02-19 Thread Mike Driscoll
On Feb 19, 12:32 pm, "steven.oldner" wrote: > Simple question but I haven't found an answer.  I program in ABAP, and > in ABAP you define the data structure of the file and move the file > line into the structure, and then do something to the fields.  That's > my mental reference. > > How do I sep

Newby Question for reading a file

2009-02-19 Thread steven.oldner
Simple question but I haven't found an answer. I program in ABAP, and in ABAP you define the data structure of the file and move the file line into the structure, and then do something to the fields. That's my mental reference. How do I separate or address each field in the file line with PYTHON