Copyright 1999-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Author: Jan Schneider (jan@horde.org)
Author: Chuck Hagenbuch (chuck@horde.org)
Inheritance: extends Horde_Data_Base
Esempio n. 1
0
 protected function readCsv($file, $conf = array())
 {
     $fp = fopen(__DIR__ . '/fixtures/getcsv/' . $file, 'r');
     $data = array();
     while ($res = Horde_Data_Csv::getCsv($fp, $conf)) {
         $data[] = $res;
     }
     return $data;
 }
Esempio n. 2
0
    public function testImportFile()
    {
        $data = new Horde_Data_Csv(new Horde_Data_Storage_Mock());
        $expected = array(array(0 => 'one', 1 => 'two', 2 => 'three four', 3 => 'five'), array(0 => 'six', 1 => 'seven', 2 => 'eight nine', 3 => 'ten'));
        $this->assertEquals($expected, $data->importFile(__DIR__ . '/fixtures/simple_dos.csv', false, ',', '', 4));
        $this->assertEquals($expected, $data->importFile(__DIR__ . '/fixtures/simple_unix.csv', false, ',', '', 4));
        $expected = array(array('one' => 'six', 'two' => 'seven', 'three four' => 'eight nine', 'five' => 'ten'));
        $this->assertEquals($expected, $data->importFile(__DIR__ . '/fixtures/simple_dos.csv', true, ',', '', 4));
        $this->assertEquals($expected, $data->importFile(__DIR__ . '/fixtures/simple_unix.csv', true, ',', '', 4));
        $expected = array(array('one' => 'four', 'two' => 'five"six', 'three' => 'seven
"eight"', '' => ''));
        $this->assertEquals($expected, $data->importFile(__DIR__ . '/fixtures/quotes1.csv', true, ',', '"', 4));
        $this->assertEquals($expected, $data->importFile(__DIR__ . '/fixtures/quotes2.csv', true, ',', '"', 4));
    }
Esempio n. 3
0
 public function exportData($data, $header = true, $export_mapping = array())
 {
     return parent::exportData($this->_map($data), $header, $export_mapping);
 }