Problem/Motivation
In the real world the header row doesn't necessary start in row 1. There are spreadsheets having the table header after a title or other content. Right now MigrateSourceSpreadsheet assumes that the header row is the first row in the spreadsheet. The only way to workaround this is to extend the class and fork a lot of code.
Proposed resolution
Introduce a first_row the $options array that is passed to constructor, defaulting to 1.
Remaining tasks
None.
User interface changes
None.
API changes
Migrations can specify a different starting row by passing the value in the $options array as first_row key.
class MyMigration extends Migration {
...
$this->source = new MigrateSourceSpreadsheet(
'foo.xls',
'Sheet1',
array('bar', 'baz', 'fooo'),
array('first_row' => 4) // The header is on the 4th row.
);
...
}
Data model changes
The content of $options array accepts an integer keyed as first_row.
Comments
Comment #1
claudiu.cristeaPatch.
Comment #2
claudiu.cristeaComment #3
mikeryanFor consistency, how about using 'header_rows' as the CSV source does?
Comment #4
claudiu.cristeaOK. I changed also the value to be "zero based" as is in csv source.
Comment #6
claudiu.cristeaOops!
Comment #8
claudiu.cristeaThe HEAD changed in the meantime :)
Interdiff against #4.
Comment #11
mikeryanI'm getting the user test failures too, without your patch - I'll open an issue for that.
Comment #12
mikeryanI think this is what broke the tests: #2504517: Respect the timezone when converting a date to a timestamp.
Comment #15
mikeryanCommitted, thanks (also for your patience with the tests!).