Class File_CSV

Description

The File_CSV package allows reading and creating of CSV data and files.

$Horde: framework/File_CSV/CSV.php,v 1.4.2.15 2009/01/06 15:23:05 jan Exp $

Copyright 2002-2003 Tomas Von Veschler Cox <cox@idecnet.com> Copyright 2005-2009 The Horde Project (http://www.horde.org/)

This source file is subject to version 2.0 of the PHP license, that is bundled with this package in the file LICENSE, and is available at through the world-wide-web at http://www.php.net/license/2_02.txt. If you did not receive a copy of the PHP license and are unable to obtain it through the world-wide-web, please send a note to license@php.net so we can mail you a copy immediately.

Located in /File_CSV/CSV.php (line 38)


	
			
Method Summary
 static array discoverFormat (string $file, [array $extraSeps = array()])
 static resource getPointer (string $file,  &$conf, [string $mode = HORDE_FILE_CSV_MODE_READ], array $conf)
 array|boolean read (string $file,  &$conf, array $conf)
 array|boolean readQuoted (string $file,  &$conf, array $conf)
 string unquote (string $field, string $quote, [string $crlf = null])
 array warning ([string $warning = null])
 boolean write (string $file, array $fields,  &$conf, array $conf)
 void _checkConfig ( &$conf, array $conf, string $error)
 integer _line ([integer $line = null])
Methods
static discoverFormat (line 54)

Discovers the format of a CSV file (the number of fields, the separator, the quote string, and the line break).

We can't use the auto_detect_line_endings PHP setting, because it's not supported by fgets() contrary to what the manual says.

  • return: The format hash.
static array discoverFormat (string $file, [array $extraSeps = array()])
  • string $file: The CSV file name
  • array $extraSeps: Extra separators that should be checked for.
static getPointer (line 503)

Returns or creates the file descriptor associated with a file.

  • return: The file resource or PEAR_Error on error.
static resource getPointer (string $file,  &$conf, [string $mode = HORDE_FILE_CSV_MODE_READ], array $conf)
  • string $file: The name of the file
  • array $conf: The configuration
  • string $mode: The open mode. HORDE_FILE_CSV_MODE_READ or HORDE_FILE_CSV_MODE_WRITE.
  • &$conf
read (line 156)

Reads a row from a CSV file and returns it as an array.

This method normalizes linebreaks to single newline characters (0x0a).

  • return: The CSV data or false if no more data available.
array|boolean read (string $file,  &$conf, array $conf)
  • string $file: The name of the CSV file.
  • array $conf: The configuration for the CSV file.
  • &$conf
readQuoted (line 233)

Reads a row from a CSV file and returns it as an array.

This method is able to read fields with multiline data and normalizes linebreaks to single newline characters (0x0a).

  • return: The CSV data or false if no more data available.
array|boolean readQuoted (string $file,  &$conf, array $conf)
  • string $file: The name of the CSV file.
  • array $conf: The configuration for the CSV file.
  • &$conf
unquote (line 433)

Removes surrounding quotes from a string and normalizes linebreaks.

  • return: The unquoted data.
string unquote (string $field, string $quote, [string $crlf = null])
  • string $field: The string to unquote.
  • string $quote: The quote character.
  • string $crlf: The linebreak character.
warning (line 478)

Adds a warning to or retrieves and resets the warning stack.

  • return: If no parameter has been specified, the list of existing warnings.
array warning ([string $warning = null])
  • string $warning: A warning string. If not specified, the existing warnings will be returned instead and the warning stack gets emptied.
write (line 393)

Writes a hash into a CSV file.

  • return: True on success, PEAR_Error on failure.
boolean write (string $file, array $fields,  &$conf, array $conf)
  • string $file: The name of the CSV file.
  • array $fields: The CSV data.
  • array $conf: The configuration for the CSV file.
  • &$conf
_checkConfig (line 539)

Checks the configuration given by the user.

void _checkConfig ( &$conf, array $conf, string $error)
  • array $conf: The configuration assoc array
  • string $error: The error will be written here if any
  • &$conf
_line (line 457)

Sets or gets the current line being parsed.

  • return: The current line.
integer _line ([integer $line = null])
  • integer $line: If specified, the current line.

Documentation generated on Sun, 30 Jan 2011 05:16:09 +0000 by phpDocumentor 1.4.3