/** * Csf files writer * * @param string $fileName Csv file name * @param array $headers * @param string $delimiter Set the field delimiter (one character only). Defaults as a comma * @param string $enclosure Set the field enclosure character (one character only). Defaults as a double quotation mark. * @param string $escapeChar Set the escape character (one character only). Defaults as a backslash (\) */ public function __construct($fileName, $headers, $delimiter = ';', $enclosure = '"') { parent::__construct($fileName); $this->setHeaders($headers); $this->delimiter = $delimiter; $this->enclosure = $enclosure; $this->setFileMode('w+'); $this->writeHeader(); }
/** * Csf files handler * * @param string $fileName Csv file name * @param string $delimiter Set the field delimiter (one character only). Defaults as a comma * @param string $enclosure Set the field enclosure character (one character only). Defaults as a double quotation mark. * @param string $escapeChar Set the escape character (one character only). Defaults as a backslash (\) * @param array $defaultHeaders Array of defaylt headers. If false, read headers from first line of csv file. */ public function __construct($fileName, $delimiter = ';', $enclosure = '"', $defaultHeaders = false) { parent::__construct($fileName); if (!$this->isExists()) { throw new Gpf_Exception($this->_('Could not open csv file.')); } $this->delimiter = $delimiter; $this->enclosure = $enclosure; if ($defaultHeaders) { $this->headers = new Gpf_Data_RecordHeader($defaultHeaders); $this->defaultHeaders = $defaultHeaders; } else { $this->headers = new Gpf_Data_RecordHeader(); } $this->rewind(); }