Newsgroups: comp.lang.python
From: paul618 <paul.nest.ce....@gmail.com>
Date: Tue, 24 Jul 2012 00:50:22 -0700 (PDT)
Local: Tues, Jul 24 2012 3:50 am
Subject: groveling over a file for Q:: and A:: stmts
#!/usr/bin/env python
# grep_for_QA.py I am only looking to isolate uniq Q:: and A:: stmts from my daily files # # note: This algorithm will fail if there are any blank lines within the Q and A area of interest (a paragraph) # D. Beazley is my fav documentation
import re, glob
sampledata = '''
'''
pattern0 = re.compile("Q::")
path = "/Users/paultaney/dailies2012/0722" # an example of real data set.
toggle = False
#file = open(path, "r")
# falsestarts::
mo0 = re.search(pattern0, line)
if mo0:
if mo1:
if mo2 and toggle:
except Exception as e:
except UnicodeDecodeError:
L.sort
# and what"s wrong with some of this, here!
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||