Re: Parse each line by character location

2008-11-05 Thread Shawn Milochik
I work with tab-delimited files for a living. Because of the same need you have, I created a Python script to do this. It has usage information that is easy to follow (just run it without any arguments). I hope someone else finds this useful. I have, and use it every month. It can be easily modifi

Re: Parse each line by character location

2008-11-05 Thread Lie
On Nov 5, 2:29 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: [snip] >         So you have a classic (especially for COBOL and older FORTRAN) fixed > field record layout, no? > >         I presume the entire file is of a single layout? That would mean > only one splitting format is needed... > [s

Re: Parse each line by character location

2008-11-05 Thread Tyler
>         So you have a classic (especially for COBOL and older FORTRAN) fixed > field record layout, no? Exactly, I believe COBOL. It is a daily reconciliation with an exchange and our system's orders. One of the problems of dealing with these old legacy systems that never seem to go away >

Re: Parse each line by character location

2008-11-04 Thread bearophileHUGS
George Sakkis: > Here's a general solution for fixed size records: > >>> def slicer(*sizes): > > ...     slices = len(sizes) * [None] > ...     start = 0 > ...     for i,size in enumerate(sizes): > ...         stop = start+size > ...         slices[i] = slice(start,stop) > ...         start = stop

Re: Parse each line by character location

2008-11-04 Thread Tim Chase
recno_idx = slice(0,10) client_idx = slice(10, 11) volume_idx = slice(11,11+10) order_type_idx = slice(11+10, 11+10+3) . !? That seems to me confusingly far from a working solution, at least in comparison to recno_idex = the_line[0:10] client_idx = the_li

Re: Parse each line by character location

2008-11-04 Thread Arnaud Delobelle
[EMAIL PROTECTED] (Cameron Laird) writes: > In article <[EMAIL PROTECTED]>, > Tim Chase <[EMAIL PROTECTED]> wrote: >>> I hope this is the right place to ask, but I am trying to come up with >>> a way to parse each line of a file. Unfortunately, the file is neither >>> comma, nor tab, nor space de

Re: Parse each line by character location

2008-11-04 Thread Benjamin Kaplan
On Tue, Nov 4, 2008 at 11:45 AM, Tyler <[EMAIL PROTECTED]> wrote: > Hello All: > > I hope this is the right place to ask, but I am trying to come up with > a way to parse each line of a file. Unfortunately, the file is neither > comma, nor tab, nor space delimited. Rather, the character locations

Re: Parse each line by character location

2008-11-04 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Tim Chase <[EMAIL PROTECTED]> wrote: >> I hope this is the right place to ask, but I am trying to come up with >> a way to parse each line of a file. Unfortunately, the file is neither >> comma, nor tab, nor space delimited. Rather, the character locations >> imply

Re: Parse each line by character location

2008-11-04 Thread Tyler
Wow! Thanks for the suggestions everyone. Cheers, t. -- http://mail.python.org/mailman/listinfo/python-list

Re: Parse each line by character location

2008-11-04 Thread George Sakkis
On Nov 4, 11:45 am, Tyler <[EMAIL PROTECTED]> wrote: > Hello All: > > I hope this is the right place to ask, but I am trying to come up with > a way to parse each line of a file. Unfortunately, the file is neither > comma, nor tab, nor space delimited. Rather, the character locations > imply what

Re: Parse each line by character location

2008-11-04 Thread Tim Chase
I hope this is the right place to ask, but I am trying to come up with a way to parse each line of a file. Unfortunately, the file is neither comma, nor tab, nor space delimited. Rather, the character locations imply what field it is. For example: The first ten characters would be the record num

Re: Parse each line by character location

2008-11-04 Thread Giorgio Gentili
Tyler ha scritto: Hello All: I hope this is the right place to ask, but I am trying to come up with a way to parse each line of a file. Unfortunately, the file is neither comma, nor tab, nor space delimited. Rather, the character locations imply what field it is. For example: The first ten cha

Parse each line by character location

2008-11-04 Thread Tyler
Hello All: I hope this is the right place to ask, but I am trying to come up with a way to parse each line of a file. Unfortunately, the file is neither comma, nor tab, nor space delimited. Rather, the character locations imply what field it is. For example: The first ten characters would be the