Propel 2 API
Class

Propel\Runtime\Parser\CsvParser

class CsvParser extends AbstractParser

CSV parser.

Converts data between associative array and CSV formats.
CSV parsing code borrowed from php-csv-utils by Luke Visinoni
http://code.google.com/p/php-csv-utils/

Constants

QUOTE_NONE

QUOTE_ALL

QUOTE_NONNUMERIC

QUOTE_MINIMAL

Properties

$delimiter
$lineTerminator
$quotechar
$escapechar
$quoting

Methods

string fromArray(array $array, boolean $isList = false, boolean $includeHeading = true)

Converts data from an associative array to CSV.

array toArray(string $data, boolean $isList = false, boolean $includeHeading = true)

Converts data from CSV to an associative array.

listFromArray($array)

listToArray($array)

string load(string $path)

Loads data from a file.

from AbstractParser
dump(string $data, string $path = null)

Dumps data to a file, or to STDOUT if no filename is given

from AbstractParser
static AbstractParser getParser(string $type = 'XML')

Factory for getting an instance of a subclass of AbstractParser

from AbstractParser
string toCSV(array $array, boolean $isList = false, boolean $includeHeading = true)

Alias for CsvParser::fromArray()

array fromCSV(string $data, boolean $isList = false, boolean $includeHeading = true)

Alias for CsvParser::toArray()

Details

at line 44
public string fromArray(array $array, boolean $isList = false, boolean $includeHeading = true)

Converts data from an associative array to CSV.

Parameters

array $array Source data to convert
boolean $isList Whether the input data contains more than one row
boolean $includeHeading Whether the output should contain a heading line

Return Value

string Converted data, as a CSV string

at line 183
public array toArray(string $data, boolean $isList = false, boolean $includeHeading = true)

Converts data from CSV to an associative array.

Parameters

string $data Source data to convert, as a CSV string
boolean $isList Whether the input data contains more than one row
boolean $includeHeading Whether the input contains a heading line

Return Value

array Converted data

at line 64
public listFromArray($array)

Parameters

$array

at line 216
public listToArray($array)

Parameters

$array

in AbstractParser at line 60
public string load(string $path)

Loads data from a file.

Executes PHP code blocks in the file.

Parameters

string $path Path to the file to load

Return Value

string The file content processed by PHP

in AbstractParser at line 79
public dump(string $data, string $path = null)

Dumps data to a file, or to STDOUT if no filename is given

Parameters

string $data The file content
string $path Path of the file to create

in AbstractParser at line 95
static public AbstractParser getParser(string $type = 'XML')

Factory for getting an instance of a subclass of AbstractParser

Parameters

string $type Parser type, amon 'XML', 'YAML', 'JSON', and 'CSV'

Return Value

AbstractParser A PropelParser subclass instance

at line 169
public string toCSV(array $array, boolean $isList = false, boolean $includeHeading = true)

Alias for CsvParser::fromArray()

Parameters

array $array Source data to convert
boolean $isList Whether the input data contains more than one row
boolean $includeHeading Whether the output should contain a heading line

Return Value

string Converted data, as a CSV string

at line 302
public array fromCSV(string $data, boolean $isList = false, boolean $includeHeading = true)

Alias for CsvParser::toArray()

Parameters

string $data Source data to convert, as a CSV string
boolean $isList Whether the input data contains more than one row
boolean $includeHeading Whether the input contains a heading line

Return Value

array Converted data