Documentation

CrmCsv
in package

Read and write CSV files

Tags
category

Csv_bv

subpackage

module_crm

author

SoftSolutions4U Development Team info@softsolutions4u.com

copyright

2012 and CLOUDREXX CMS - CLOUDREXX AG

license

trial license

link
www.cloudrexx.com

Table of Contents

Properties

$mFldEscape  : string
Escape character
$mFldQuote  : string
Quote character
$mFldSeparator  : string
Separator character
$mHandle  : resource
Holds the file handle
$mRowCount  : int
Counts the number of rows that have been returned
$mRowSize  : int
Length of the largest row in bytes
$mSkipEmptyRows  : bool
Determines whether empty rows should be skipped.
$mSkippedRowCount  : int
Counts the number of empty rows that have been skipped
$mTrimFields  : bool
Specifies whether the fields leading and trailing \s and \t should be removed.

Methods

__construct()  : mixed
Constructor
ArrayRemoveEscape()  : mixed
Escape the quote character
ArrayTrim()  : mixed
Strip leading and trailing whitespace from the elements of an array
Csv2Array()  : mixed
csv::Csv2Array will return the whole csv file as 2D array
NextLine()  : array<string|int, mixed>
csv::NextLine() returns an array of fields from the next csv line.
RowCount()  : int
csv::RowCount return the current row count
SkipEmptyRows()  : void
csv::SkipEmptyRows, sets whether empty rows should be skipped or not
SkippedRowCount()  : int
csv::RowCount return the current skipped row count
TrimFields()  : void
csv::TrimFields, sets whether fields should have their \s and \t removed.
write()  : array<string|int, mixed>
Writes the array to the CSV file

Properties

$mFldEscape

Escape character

private string $mFldEscape = '\\'
Tags
access

private

$mFldQuote

Quote character

private string $mFldQuote = '"'
Tags
access

private

$mFldSeparator

Separator character

private string $mFldSeparator = ';'
Tags
access

private

$mHandle

Holds the file handle

private resource $mHandle = null
Tags
access

private

$mRowCount

Counts the number of rows that have been returned

private int $mRowCount = 0
Tags
access

private

$mRowSize

Length of the largest row in bytes

private int $mRowSize = 4096
Tags
access

private

$mSkipEmptyRows

Determines whether empty rows should be skipped.

private bool $mSkipEmptyRows = false

By default empty rows are NOT skipped.

Tags
access

private

$mSkippedRowCount

Counts the number of empty rows that have been skipped

private int $mSkippedRowCount = 0
Tags
access

private

$mTrimFields

Specifies whether the fields leading and trailing \s and \t should be removed.

private bool $mTrimFields = true

Defaults to true.

Tags
access

private

Methods

__construct()

Constructor

public __construct([str $file = '' ][, str $separator = ';' ][, str $quote = '"' ][, str $escape = '\' ]) : mixed

Only initialises class settings variables.

Parameters
$file : str = ''
  • file path
$separator : str = ';'
  • Only one character is allowed (optional)
$quote : str = '"'
  • Only one character is allowed (optional)
$escape : str = '\'
  • Only one character is allowed (optional)
Tags
access

public

ArrayRemoveEscape()

Escape the quote character

public ArrayRemoveEscape(Address &$item) : mixed

Called by array_walk()

Parameters
$item : Address
Tags
access

private

ArrayTrim()

Strip leading and trailing whitespace from the elements of an array

public ArrayTrim(Address &$item) : mixed

Called by array_walk(). Spaces and tabs are removed (\s and \t).

Parameters
$item : Address
Tags
access

private

Csv2Array()

csv::Csv2Array will return the whole csv file as 2D array

public Csv2Array() : mixed
Tags
access

public

NextLine()

csv::NextLine() returns an array of fields from the next csv line.

public NextLine() : array<string|int, mixed>

The position of the file pointer is stored in PHP internals. Empty rows can be skipped. Leading and trailing \s and \t can be removed from each field.

Tags
access

public

Return values
array<string|int, mixed>

of fields

RowCount()

csv::RowCount return the current row count

public RowCount() : int
Tags
access

public

Return values
int

SkipEmptyRows()

csv::SkipEmptyRows, sets whether empty rows should be skipped or not

public SkipEmptyRows([bool $bool = true ]) : void
Parameters
$bool : bool = true
Tags
access

public

SkippedRowCount()

csv::RowCount return the current skipped row count

public SkippedRowCount() : int
Tags
access

public

Return values
int

TrimFields()

csv::TrimFields, sets whether fields should have their \s and \t removed.

public TrimFields([bool $bool = true ]) : void
Parameters
$bool : bool = true
Tags
access

public

write()

Writes the array to the CSV file

public write(string $filename, array<string|int, mixed> $arrCsv) : array<string|int, mixed>
Parameters
$filename : string
$arrCsv : array<string|int, mixed>
Tags
access

public

static
Return values
array<string|int, mixed>

of fields


        
On this page

Search results