Overview

Packages

  • Data

Classes

  • Horde_Data
  • Horde_Data_Base
  • Horde_Data_Csv
  • Horde_Data_Exception
  • Horde_Data_Icalendar
  • Horde_Data_Imc
  • Horde_Data_Outlookcsv
  • Horde_Data_Translation
  • Horde_Data_Tsv
  • Horde_Data_Vcard
  • Horde_Data_Vnote
  • Horde_Data_Vtodo
  • Overview
  • Package
  • Class
  • Tree

Class Horde_Data_Csv

Horde_Data implementation for comma-separated data (CSV).

Copyright 1999-2012 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.

Horde_Data_Base
Extended by Horde_Data_Csv

Direct known subclasses

Horde_Data_Outlookcsv
Package: Data
Category: Horde
Author: Jan Schneider jan@horde.org
Author: Chuck Hagenbuch chuck@horde.org
Located at Horde/Data/Csv.php
Methods summary
public
# __construct( array $params = array() )

Constructor.

Constructor.

Parameters

$params
Optional parameters: <pre><span class="php-quote">'charset'</span> - (string) The <span class="php-keyword1">default</span> charset. <span class="php-keyword1">DEFAULT</span>: NONE</pre>

Throws

InvalidArgumentException

Overrides

Horde_Data_Base::__construct()
public array
# importFile( string $filename, boolean $header = false, string $sep = ',', string $quote = '', integer $fields = null, string $import_mapping = array(), string $charset = null, mixed $crlf = null )

Imports and parses a CSV file.

Imports and parses a CSV file.

Parameters

$filename
The name of the file to parse.
$header
<p>Does the first line contain the field/column names?</p>
$sep
The field/column separator.
$quote
The quoting character.
$fields
The number or fields/columns.
$import_mapping
$charset The file's charset.
$charset
$crlf The file's linefeed characters.
$crlf

Returns

array

A two-dimensional array of all imported data rows. If $header was true the rows are associative arrays with the field/column names as the keys.

Throws

Horde_Data_Exception

Overrides

Horde_Data_Base::importFile()
public string
# exportData( array $data, boolean $header = false, mixed $export_mapping = array() )

Builds a CSV file from a given data structure and returns it as a string.

Builds a CSV file from a given data structure and returns it as a string.

Parameters

$data
A two-dimensional array containing the data set.
$header
<p>If true, the rows of $data are associative arrays with field names as their keys.</p>
$export_mapping

Returns

string
The CSV data.
public
# exportFile( string $filename, array $data, boolean $header = false, mixed $export_mapping = array() )

Builds a CSV file from a given data structure and triggers its download. It DOES NOT exit the current script but only outputs the correct headers and data.

Builds a CSV file from a given data structure and triggers its download. It DOES NOT exit the current script but only outputs the correct headers and data.

Parameters

$filename
The name of the file to be downloaded.
$data
<p>A two-dimensional array containing the data set.</p>
$header
<p>If true, the rows of $data are associative arrays with field names as their keys.</p>
$export_mapping
public mixed
# nextStep( integer $action, array $param = array() )

Takes all necessary actions for the given import step, parameters and form values and returns the next necessary step.

Takes all necessary actions for the given import step, parameters and form values and returns the next necessary step.

Parameters

$action
The current step. One of the IMPORT_* constants.
$param
<p>An associative array containing needed parameters for the current step.</p>

Returns

mixed

Either the next step as an integer constant or imported data set after the final step.

Throws

Horde_Data_Exception

Overrides

Horde_Data_Base::nextStep()
Methods inherited from Horde_Data_Base
cleanup(), getContentType(), getFilename(), getNewline(), importData(), warnings()
API documentation generated by ApiGen