collecting data from file
Peter Hansen
peter at engcorp.com
Fri Apr 11 08:36:12 EDT 2003
Mustafa Celik wrote:
>
> I want to scroll thru a file;
> * find lines that match a string (e.g. HELLO) on the 2nd column
> * add up the 4th column (an integer) on each matching line, say the
> variable is TOTAL
> * subtract the 4th column from TOTAL if another is string (e.g. BYE)
> is hit on 2nd column of a line
>
> Any tips?
Yes, post an example showing what you intend. The instructions are
decent, but implementable only by making a few assumptions about what
you mean. Also, are there any error conditions to be handled, or do
you guarantee the input is always perfect (e.g., always at least four
columns, and so on)?
-Peter
More information about the Python-list
mailing list