Author: mcantelon
Date: Tue Jan 10 15:07:49 2012
New Revision: 10634
Log:
Added ability to skip rows (so you can test different parts of an import
easily).
Modified:
trunk/lib/QubitFlatfileImport.class.php
trunk/lib/task/csvImportTask.class.php
Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php Tue Jan 10 14:49:18 2012
(r10633)
+++ trunk/lib/QubitFlatfileImport.class.php Tue Jan 10 15:07:49 2012
(r10634)
@@ -58,7 +58,7 @@
$this->setPropertiesFromArray($this, $options, $allowedOptions);
// initialize bookkeeping of rows processed
- $this->status = ($options['status']) ? $options['status'] : array();
+ $this->status = ($options['status']) ? $options['status'] : $this->status;
$this->status['rows'] = 0;
// initialize row status variables
@@ -225,8 +225,10 @@
return $this->timer->elapsed();
}
- public function csv($fh)
+ public function csv($fh, $skipRows = 0)
{
+ $this->status['skippedRows'] = $skipRows;
+
// inform user of any columns not included in import
print $this->renderUnhandledColumns();
@@ -234,13 +236,25 @@
// columns
print $this->renderUnmatchedColumns();
- $this->startTimer();
+ if ($skipRows) print "Skipped ". $skipRows ." rows...\n";
+
+ $timerStarted = FALSE;
// import each row
while ($item = fgetcsv($fh, 60000))
{
- print '.';
- $this->row($item);
+ if ($this->status['rows'] >= $skipRows)
+ {
+ if (!$timerStarted)
+ {
+ $this->startTimer();
+ $timerStarted = TRUE;
+ }
+ print '.';
+ $this->row($item);
+ } else {
+ $this->status['rows']++;
+ }
}
$this->stopTimer();
Modified: trunk/lib/task/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/csvImportTask.class.php Tue Jan 10 14:49:18 2012
(r10633)
+++ trunk/lib/task/csvImportTask.class.php Tue Jan 10 15:07:49 2012
(r10634)
@@ -483,7 +483,7 @@
if ($options = $self->getStatus('options'))
{
// row count isn't incremented until completion of this closure,
so add one to reflect reality
- $rowsProcessed = $self->getStatus('rows') + 1;
+ $rowsProcessed = $self->getStatus('rows') + 1 -
$self->getStatus('skippedRows');
$memoryUsageMB = round(memory_get_usage() / (1024 * 1024), 2);
if ($options['rows-until-update'] && !($rowsProcessed %
$options['rows-until-update']))
{
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.