ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCSVReader Class Reference
+ Collaboration diagram for ilCSVReader:

Public Member Functions

 __construct ()
 Constructor.
 setSeparator ($a_sep)
 setDelimiter ($a_del)
 Set delimiter.
 setLength ($a_length)
 Set length.
 open ($file="")
 close ()
 getDataArrayFromCSVFile ()
 Get data as array from csv file.

Private Member Functions

 unquote ($a_str)
 private

Private Attributes

 $ptr_file = null
 $data = array()
 $separator = ';'
 $delimiter = '""'
 $length = 1024

Detailed Description

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 34 of file class.ilCSVReader.php.

Constructor & Destructor Documentation

ilCSVReader::__construct ( )

Constructor.

public

Parameters

Definition at line 49 of file class.ilCSVReader.php.

{
}

Member Function Documentation

ilCSVReader::close ( )

Definition at line 95 of file class.ilCSVReader.php.

{
return( @fclose($this->ptr_file) );
}
ilCSVReader::getDataArrayFromCSVFile ( )

Get data as array from csv file.

public

Returns
array $this->data Data of file

Definition at line 107 of file class.ilCSVReader.php.

References $data, $row, and unquote().

{
$row = 0;
while (($line = fgetcsv($this->ptr_file, $this->length, $this->separator)) !== FALSE)
{
for ($col = 0; $col < count($line); $col++)
{
$this->data[$row][$col] = $this->unquote($line[$col]);
}
++$row;
}
return $this->data;
}

+ Here is the call graph for this function:

ilCSVReader::open (   $file = "")

Definition at line 90 of file class.ilCSVReader.php.

References $file, and ilUtil\stripSlashes().

{
return( $this->ptr_file = @fopen(ilUtil::stripSlashes($file), "r") );
}

+ Here is the call graph for this function:

ilCSVReader::setDelimiter (   $a_del)

Set delimiter.

public

Parameters
stringfield delimiter

Definition at line 73 of file class.ilCSVReader.php.

{
$this->delimiter = $a_del;
}
ilCSVReader::setLength (   $a_length)

Set length.

public

Parameters
intlength

Definition at line 85 of file class.ilCSVReader.php.

{
$this->length = $a_length;
}
ilCSVReader::setSeparator (   $a_sep)

Definition at line 61 of file class.ilCSVReader.php.

{
$this->separator = $a_sep;
}
ilCSVReader::unquote (   $a_str)
private

private

Parameters
stringfield value

Definition at line 130 of file class.ilCSVReader.php.

Referenced by getDataArrayFromCSVFile().

{
return str_replace($this->delimiter.$this->delimiter, $this->delimiter,$a_str);
}

+ Here is the caller graph for this function:

Field Documentation

ilCSVReader::$data = array()
private

Definition at line 37 of file class.ilCSVReader.php.

Referenced by getDataArrayFromCSVFile().

ilCSVReader::$delimiter = '""'
private

Definition at line 39 of file class.ilCSVReader.php.

ilCSVReader::$length = 1024
private

Definition at line 40 of file class.ilCSVReader.php.

ilCSVReader::$ptr_file = null
private

Definition at line 36 of file class.ilCSVReader.php.

ilCSVReader::$separator = ';'
private

Definition at line 38 of file class.ilCSVReader.php.


The documentation for this class was generated from the following file: