Public Member Functions | |
getDataPairs ($file, $keyIndex=0, $valueIndex=1) |
Definition at line 35 of file CsvMulty.php.
getDataPairs | ( | $ | file, | |
$ | keyIndex = 0 , |
|||
$ | valueIndex = 1 | |||
) |
Retrieve CSV file data as pairs with duplicates
string | $file | |
int | $keyIndex | |
int | $valueIndex |
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 }