[Baypiggies] Help with code
Andy Wiggin
andywiggin at gmail.com
Sat Nov 24 00:16:00 CET 2007
in "elif line(-1) == 'F' and line(1) != ' ':", it looks like you need
[], not () for subscripting the string. -andy
On Nov 23, 2007 3:04 PM, Alden Meneses <aldenm at gmail.com> wrote:
> 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.
> f.close()
> print edit
>
>
> I get this error message -
>
> Traceback (most recent call last):
> File
> "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
> 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,
> Alden
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
> http://mail.python.org/mailman/listinfo/baypiggies
>
More information about the Baypiggies
mailing list