当前位置: 首页>>代码示例>>PHP>>正文


PHP Reader::setOffset方法代码示例

本文整理汇总了PHP中League\Csv\Reader::setOffset方法的典型用法代码示例。如果您正苦于以下问题:PHP Reader::setOffset方法的具体用法?PHP Reader::setOffset怎么用?PHP Reader::setOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在League\Csv\Reader的用法示例。


在下文中一共展示了Reader::setOffset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parseCsvFile

 /**
  * Parses a csv file into a DataTable.
  *
  * Pass in a filepath to a csv file and an array of column types:
  * ['date', 'number', 'number', 'number'] for example and a DataTable
  * will be built.
  *
  * @access public
  * @since  1.0.0
  * @param  string $filepath    Path location to a csv file
  * @param  array  $columnTypes Array of column types to apply to the csv values
  * @throws \Khill\Lavacharts\Exceptions\InvalidFunctionParam
  * @return \Khill\Lavacharts\DataTable
  */
 public function parseCsvFile($filepath, $columnTypes = null)
 {
     if (Utils::nonEmptyString($filepath) === false) {
         throw new InvalidFunctionParam($filepath, __FUNCTION__, 'string');
     }
     $this->addNewColumns($columnTypes);
     $this->setReader(Reader::createFromPath($filepath));
     $this->reader->setFlags(\SplFileObject::READ_AHEAD | \SplFileObject::SKIP_EMPTY);
     $csvColumns = $this->reader->fetchOne();
     foreach ($this->newColumns as $index => $column) {
         if (in_array($column, $this->columnTypes, true) === false) {
             throw new InvalidColumnType($column, Utils::arrayToPipedString($this->columnTypes));
         }
         $this->addColumnFromStrings($columnTypes[$index], $csvColumns[$index]);
     }
     $csvRows = $this->reader->setOffset(1)->fetchAll(function ($row) {
         return array_map(function ($cell) {
             if (is_numeric($cell)) {
                 return $cell + 0;
             } else {
                 return $cell;
             }
         }, $row);
     });
     return $this->addRows($csvRows);
 }
开发者ID:phillipmadsen,项目名称:datatableplus,代码行数:40,代码来源:DataTablePlus.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->promptForCredentials($input, $output);
     $dstPath = $input->getArgument('dst_path');
     $csvPath = $input->getArgument('csv_path');
     $reader = new Reader($csvPath);
     $csv = $reader->setOffset(1)->fetchAll();
     // Create destination folder.
     mkdir($dstPath, 0777, true);
     if (!is_writeable($dstPath)) {
         die("OMERGERD COULDN'T WRITE TO DIRECTORY!!!");
     }
     foreach ($csv as $row) {
         list($sslId, $cn, $status) = array($row[0], $row[2], $row[4]);
         if ($status != 'Issued') {
             $output->writeln(sprintf("<info>%s is %s. Skipping...</info>", $cn, $status));
             continue;
         }
         $output->writeln(sprintf("%s (%s): %s", $cn, $sslId, $status));
         $response = $this->incommon->certs->collect($this->authData, $sslId, 1);
         // Get cert contents.
         $certData = $response->SSL->certificate;
         // Clean * out of CN
         $filename = str_replace('*', 'star', $cn);
         // Write file
         $filepath = "{$dstPath}/{$filename}.crt";
         $fp = fopen($filepath, "w");
         fwrite($fp, $certData);
         fclose($fp);
     }
 }
开发者ID:mdwheele,项目名称:incommon-cli,代码行数:31,代码来源:CollectCertCommand.php

示例3: setDefaultsFromFile

 /**
  * Set the metadata from a file.
  *
  * @param string $file
  */
 public function setDefaultsFromFile($file)
 {
     $file = new Reader($file);
     // Fetch columns
     $rows = $file->fetchOne();
     $file->setOffset(1);
     // Fetch entries and set defaults
     $entries = $file->fetchAssoc($rows);
     foreach ($entries as $entry) {
         if (strpos(URL::current(), $entry['url']) !== false) {
             $this->defaults = $entry;
         }
     }
 }
开发者ID:anahkiasen,项目名称:arrounded,代码行数:19,代码来源:Metadata.php


注:本文中的League\Csv\Reader::setOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。