Varien_File_Csv_Multy Class Reference

Inheritance diagram for Varien_File_Csv_Multy:

Varien_File_Csv

List of all members.

Public Member Functions

 getDataPairs ($file, $keyIndex=0, $valueIndex=1)


Detailed Description

Csv parse

Author:
Magento Core Team <core@magentocommerce.com>

Definition at line 35 of file CsvMulty.php.


Member Function Documentation

getDataPairs ( file,
keyIndex = 0,
valueIndex = 1 
)

Retrieve CSV file data as pairs with duplicates

Parameters:
string $file
int $keyIndex
int $valueIndex
Returns:
array

Reimplemented from Varien_File_Csv.

Definition at line 44 of file CsvMulty.php.

00045     {
00046         $data = array();
00047         $csvData = $this->getData($file);
00048         $line_number = 0;
00049         foreach ($csvData as $rowData) {
00050             $line_number++;
00051             if (isset($rowData[$keyIndex])) {
00052                 if(isset($data[$rowData[$keyIndex]])){
00053                     if(isset($data[$rowData[$keyIndex]]['duplicate'])){
00054                         #array_push($data[$rowData[$keyIndex]]['duplicate'],array('line' => $line_number,'value' => isset($rowData[$valueIndex]) ? $rowData[$valueIndex] : null));                      
00055                         $data[$rowData[$keyIndex]]['duplicate']['line'] .=', '.$line_number; 
00056                     } else {
00057                         $tmp_value = $data[$rowData[$keyIndex]]['value'];
00058                         $tmp_line  = $data[$rowData[$keyIndex]]['line'];
00059                         $data[$rowData[$keyIndex]]['duplicate'] = array();
00060                         #array_push($data[$rowData[$keyIndex]]['duplicate'],array('line' => $tmp_line.' ,'.$line_number,'value' => $tmp_value));
00061                         $data[$rowData[$keyIndex]]['duplicate']['line'] = $tmp_line.' ,'.$line_number;
00062                         $data[$rowData[$keyIndex]]['duplicate']['value'] = $tmp_value;
00063                     }
00064                 } else {
00065                     $data[$rowData[$keyIndex]] = array();
00066                     $data[$rowData[$keyIndex]]['line'] = $line_number;
00067                     $data[$rowData[$keyIndex]]['value'] = isset($rowData[$valueIndex]) ? $rowData[$valueIndex] : null;
00068                 }
00069             }
00070         }
00071         return $data;
00072     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:25:02 2009 for Magento by  doxygen 1.5.8