Kent: The code is below. Here's the error message.
Traceback (most recent call last): File "C:/Python24/reformat.py", line 5, in -toplevel- name = x.group(1) AttributeError: 'list' object has no attribute 'group' import re f = open('reformat.txt').read() pat = re.compile(r"([^\r\n]+)\n([^\r\n]*)\n([^\r\n]*) ([^\r\n]*) ([^\r\n]*)") x=re.findall(pat,f) name = x.group(1) address = x.group(2) citystate = x.group(3)+x.group(4) zipcd = x.group(5) o= open('reformat1.txt','w') o.write("%s,%s,%s,%s\n" % (name, address, citystate,zipcd)) o.close() print("%s,%s,%s,%s\n" % (name, address, citystate,zipcd)) --- Kent Johnson <[EMAIL PROTECTED]> wrote: > Ron Nixon wrote: > > Thanks to all who replied to my post earlier on > re's. > > I'm still preplexed by why re.search and re.match > > works in the code below, but not re.findall. > > re.findall is suppose to return all > non-voerlapping > > occurances of the pattern that matches in this > > example, but it returns errors. Looking through > the > > docs and from what I can see it should work. Can > > anyone provide advice. > > Please show the code that uses re.findall() and the > error you receive when you run it. > > Kent > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > __________________________________ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor