Python editing .txt file

Terry Reedy tjreedy at udel.edu
Wed Jun 16 00:44:50 EDT 2010


On 6/15/2010 9:28 PM, 187braintrust at berkeley.edu wrote:
> I am trying to write a program in Python that will edit .txt log files
> that contain regression output from R.  Any thoughts or suggestions
> would be greatly appreciated.

I once wrote programs (in C, Python should be easier) to process bmdp 
statistical output. I usually took a state machine approach, where each 
state corresponded to a block of output. The state machine was hard 
coded rather than table driven.

For each block, read a line, analyze it to determine whether it signals 
a transition, and process as appropriate to the state.

When states followed in strict sequence A > B > C, etc, the code was 
pretty easy, with a block of code, typically with a loop, for each 
state. When loops were possible, then a master loop with 'if state is 
A:' conditionals for each.

Good luck.

Terry Jan Reedy






More information about the Python-list mailing list