in reply to Parsing horizontal table in Excel & loading it into a database
Perhaps stating it slightly-differently: first, walk along the names-column-header row, looking to find the first row that is blank, or maybe, the last one that is not. (If you detect at this point that there are no names, or that there are blank columns within the list, die().) Now, you know the range of columns to be processed.
I would also examine the row-header columns, either to locate those rows or to die() if the spreadsheet is not exactly as expected. Now, you know, or have confirmed, which rows you need to look at. The necessary loop naturally follows.
FYI... I always code such programs very suspiciously. “Trust, but verify.™” Spreadsheet users can do anything they wish, and sometimes do, even by mistake. This can cause a subsequent computer program to commit the worst possible sin: to “appear to work correctly,” but to produce the wrong results. No one will know. Therefore, a little extra time spent verifying the expected content of rows and columns, by means of regular expressions, with die() being the response if anything appears not-right, makes for a much more robust and reliable program. If such a program runs to completion (and if its various tests have actually been tested!), then it serves as a positive indicator that its outputs (and, its inputs) are plausible.
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parsing horizontal table in Excel & loading it into a database
by marinersk (Priest) on Jun 10, 2015 at 17:39 UTC |