예제 #1
0
파일: CSV.php 프로젝트: amdg2/kiss
 public function toJson()
 {
     $this->openFile();
     $output = array();
     foreach ($this->fileContent as $line) {
         $buff = new CSVRecord(explode($this->separator, $line), $this->columns);
         $output[] = $buff->toArray();
     }
     return json_encode($output);
 }
예제 #2
0
 public function parseLines(string $lines) : \Iterator
 {
     $schema = $this->getSchema();
     $lines = $this->getLines($lines);
     $indices = array_keys($lines);
     return new \ArrayIterator(array_map(function ($values, $index) use($schema) {
         return CSVRecord::create($schema, $index, $values);
     }, $lines, $indices));
 }