Author: mcantelon
Date: Thu Feb 16 14:55:30 2012
New Revision: 10924
Log:
Integrating some logic used in CSV transformations with the QubitFlatfileImport
class.
Modified:
trunk/lib/QubitFlatfileImport.class.php
Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php Thu Feb 16 14:40:05 2012
(r10923)
+++ trunk/lib/QubitFlatfileImport.class.php Thu Feb 16 14:55:30 2012
(r10924)
@@ -38,6 +38,7 @@
public $columnNames = array(); // column names from first row of
imported CSV
public $ignoreColumns = array(); // columns in CSV to ignore
public $renameColumns = array(); // CSV header column substitutions
+ public $addColumns = array(); // columns to add to internal row buffer
public $standardColumns = array(); // columns in CSV are object properties
public $columnMap = array(); // columns in CSV that map to object
properties
@@ -370,6 +371,12 @@
$this->columnNames = fgetcsv($fh, 60000);
$this->handleColumnRenaming();
+ // add virtual columns (for column amalgamation, etc.)
+ foreach($this->addColumns as $column)
+ {
+ $this->columnNames[] = $column;
+ }
+
if ($this->showColumnUsage)
{
// inform user of any columns not included in import
@@ -427,6 +434,15 @@
// stash raw row data so it's accessible to closure logic
$this->status['row'] = $row;
+ // make row data match columns (in case virtual columns have been added)
+ foreach(array_keys($this->columnNames) as $key)
+ {
+ if (!isset($this->status['row'][$key]))
+ {
+ $this->status['row'][$key] = '';
+ }
+ }
+
// set row status variables that are based on column values
$this->rowProcessingBeforeObjectCreation($row);
--
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.