January 2013
Intermediate to advanced
328 pages
8h 5m
English
While we have already seen a basic CSV grammar in Pattern: Sequence, let’s beef it up with the notion of a header row and allow empty columns. Here’s a representative input file:
| | Details,Month,Amount |
| | Mid Bonus,June,"$2,000" |
| | ,January,"""zippo""" |
| | Total Bonuses,"","$5,000" |
Header rows are no different from regular rows; we simply interpret the column value as the column header name. Rather than using a row+ ANTLR fragment to match rows as well as the header row, we match it separately. When building a real application based upon this grammar, we’d probably want to treat the header differently. This way, we can get a handle on the first special row. Here’s the first part of the grammar:
Read now
Unlock full access