/** * Test do not skip empty lines (default behaviour) */ public function testDoNotSkipEmptyLines() { $i = 0; while (($line = $this->reader->getLine()) !== null) { ++$i; } $this->assertEquals(5, $i); $this->assertEquals(5, $this->reader->getLineNumber()); }
/** * Test write to file and the read from that file */ public function testIO() { $data = [1, 2, 'a']; $this->writer->printLine($data); $reader = new CsvReader($this->writer->getFilePath(), $this->separator); $line = $reader->getLine(); $this->assertEquals($data, $line); $this->assertNull($reader->getLine()); $reader->close(); }
/** * @param string $filepath the path to a file containing tokens (one on every line * with no header!). * * @param string $delimiter as expected by Fiedsch\Data\File\CsvReader */ public function readFromFile($filepath, $delimiter = "\t") { $reader = new CsvReader($filepath, $delimiter); $this->tokensReadFromFile = []; while (($line = $reader->getLine()) !== null) { if (!$reader->isEmpty($line)) { $this->tokensReadFromFile[] = $line[0]; // we expect the token in the first column // the second column might contain further info such as "use this many times" } } }