示例#1
0
 /**
  * Get header of the file
  *
  * @param $injectionData
  * @param $header_present
  *
  * @return array with the datas from the header
  **/
 static function getHeader(PluginDatainjectionData $injectionData, $header_present)
 {
     if ($header_present) {
         return $injectionData->getDataAtLine(0);
     }
     $nb = count($injectionData->getDataAtLine(0));
     for ($i = 0; $i < $nb; $i++) {
         $header[] = $i;
     }
     return $header;
 }
示例#2
0
 /**
  * Read a CSV file and store data in an array
  *
  * @param $numberOfLines inumber of lines to be read (-1 means all file) (default 1)
  **/
 function read($numberOfLines = 1)
 {
     $injectionData = new PluginDatainjectionData();
     $this->openFile();
     $continue = true;
     $data = false;
     for ($index = 0; ($numberOfLines == -1 || $index < $numberOfLines) && $continue; $index++) {
         $data = $this->getNextLine();
         if ($data) {
             $injectionData->addToDatas($data);
         } else {
             $continue = false;
         }
     }
     $this->closeFile();
     return $injectionData;
 }