Look at: len = len(text)
You're overriding `len` (a built-in method), with an integer (`len(text)`). You then call:
for i in range(len(fields)): But `len` is no longer a callable, but merely an integer. Regards, Friðrik MárP.S. While this is a fairly obvious problem it's usually a good idea to post working code and a traceback when requesting help.
-- http://mail.python.org/mailman/listinfo/python-list