[Baypiggies] Help with code

Alden Meneses aldenm at gmail.com
Sat Nov 24 00:04:10 CET 2007

Hello All,

I am playing with python to work read some text files and help me gather
some data. I have some further reading to do and was hoping some of you can
help point me in the right direction. This is what I have so far.

f = open('H:\xxxx\xxxx\xxxx\9-7-07')
#File is a report that summarizes each account by account group and service
area then has the details for each account and Totals before the next group
of accounts.
edit = ["GRP", "AREA", "CHARGES"]
ptype = "NULL"
area = "NULL"
for line in f:
    if line[:12] == 'ACCOUNT GROUP':
        ptype = line[16:]                                   # The account
group starts on the 16th character of the line
    elif line[:11] == 'SERVICE AREA':
        area = line[11:]                                    # The service
area starts on the 11th character of the line
    elif line(-1) == 'F' and line(1) != ' ':
        edit.append(ptype,area,line[56:66])        # I wanted to append the
edit stack with the variables collected above.
print edit

I get this error message -

Traceback (most recent call last):
line 310, in RunScript
    exec codeObject in __main__.__dict__
  File "C:\Documents and Settings\menesea\My Documents\scripts\readfile.py",
line 11, in <module>
    elif line(-1) == 'F' and line(1) != ' ':
TypeError: 'str' object is not callable

Thanks in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/baypiggies/attachments/20071123/e68ab048/attachment.htm 

More information about the Baypiggies mailing list