/** * Write data * * @param array $data */ public function writeData(array $data) { if (static::$write) { $res = self::$writer->addDocument(['id' => self::$line] + $data); self::$line++; } }
public function testTsvAction() { $data = [['id' => '1', 'name' => 'ciao', 'a' => 'mondo'], ['id' => '2', 'name' => 'hello', 'a' => 'world']]; $writer = new TSV(); $writer->openURI('tsv.tsv'); echo $writer->beginOutput(); foreach ($data as $doc) { echo $writer->addDocument($doc); sleep(5); } echo $writer->endOutput(); }