Parsing all the way through the pdf appears to work. Next we need

to track the beginning/ending points for each record and append
continuation records onto the previous. There's some issue in
the pyaccuwage-pdfparse script causing it to have problems reading
the last record field in a record group. Maybe the record extractor
needs to dump the last failed ColumnCollector rather than return it
if it's determined to hold junk data?

The record builder seems to handle everything just fine.

Added a function to the field name parsing to replace ampersands
with an "and" string so as not to cause problems with variable names.
This commit is contained in:
Binh 2012-11-13 15:53:41 -06:00
parent fe4bd20bad
commit 1c7533973a
3 changed files with 74 additions and 71 deletions

View file

@ -32,11 +32,23 @@ doc = PDFRecordFinder(source_file)
records = doc.records()
builder = RecordBuilder()
def record_begins_at(record):
return int(record[1][1].data.values()[0].split('-')[0], 10)
def record_ends_at(record):
return record[1][-1].data
return int(record[1][-1].data.values()[0].split('-')[-1], 10)
for rec in records:
print record_begins_at(rec) #, 'to', record_ends_at(rec)
# FIXME record_ends_at is randomly exploding due to record data being
# a lump of text and not necessarily a field entry. I assume
# this is cleaned out by the record builder class.
sys.stdout.write("class %s(object):\n" % re.sub('[^\w]','',rec[0]))
for field in builder.load(map(lambda x:x.tuple, rec[1][1:])):
sys.stdout.write('\t' + field + '\n')
#print field