include/parsecsv.lib.php

Show: inherited
Table of Contents

\parseCSV

Package:

Properties

Propertypublic  $auto_depth= '15'
Default value15Details
Type
n/a
Propertypublic  $auto_non_chars= '"a-zA-Z0-9\n\r"'
Default value"a-zA-Z0-9\n\r"Details
Type
n/a
Propertypublic  $auto_preferred= '",;\t.:|"'
Default value",;\t.:|"Details
Type
n/a
Propertypublic  $conditions= 'null'
Default valuenullDetails
Type
n/a
Propertypublic  $convert_encoding= 'false'
Default valuefalseDetails
Type
n/a
Propertypublic  $data= 'array()'
Default valuearray()Details
Type
n/a
Propertypublic  $delimiter= '',''
Default value','Details
Type
n/a
Propertypublic  $enclosure= ''"''
Default value'"'Details
Type
n/a
Propertypublic  $error= '0'
Default value0Details
Type
n/a
Propertypublic  $error_info= 'array()'
Default valuearray()Details
Type
n/a
Propertypublic  $fields= 'array()'
Default valuearray()Details
Type
n/a
Propertypublic  $file= ''

Internal variables

Details
Type
n/a
Propertypublic  $file_data= ''
Details
Type
n/a
Propertypublic  $heading= 'true'

Configuration - set these options with $object->var_name = 'value';

Default valuetrueDetails
Type
n/a
Propertypublic  $input_encoding= ''ISO-8859-1''
Default value'ISO-8859-1'Details
Type
n/a
Propertypublic  $keep_file_data= 'false'
Default valuefalseDetails
Type
n/a
Propertypublic  $limit= 'null'
Default valuenullDetails
Type
n/a
Propertypublic  $linefeed= '"\r\n"'
Default value"\r\n"Details
Type
n/a
Propertypublic  $offset= 'null'
Default valuenullDetails
Type
n/a
Propertypublic  $output_delimiter= '',''
Default value','Details
Type
n/a
Propertypublic  $output_encoding= ''ISO-8859-1''
Default value'ISO-8859-1'Details
Type
n/a
Propertypublic  $output_filename= ''data.csv''
Default value'data.csv'Details
Type
n/a
Propertypublic  $sort_by= 'null'
Default valuenullDetails
Type
n/a
Propertypublic  $sort_reverse= 'false'
Default valuefalseDetails
Type
n/a
Propertypublic  $sort_type= 'null'
Default valuenullDetails
Type
n/a
Propertypublic  $titles= 'array()'
Default valuearray()Details
Type
n/a

Methods

methodpublic_check_count(  $char,  $array,  $depth,  $preferred ) : \special

Check if passed info might be delimiter - only used by find_delimiter()

Parameters
Name Type Description
$char
$array
$depth
$preferred
Returns
Type Description
\special string used for delimiter selection, or false
methodpublic_check_data( \file $file = null ) : true

Check file data

Parameters
Name Type Description
$file \file

local filename

Returns
Type Description
true or false
methodpublic_enclose_value( \value $value = null ) : \Processed

Enclose values if needed - only used by unparse()

Parameters
Name Type Description
$value \value

string to process

Returns
Type Description
\Processed value
methodpublic_rfile( \file $file = null ) : \Data

Read local file

Parameters
Name Type Description
$file \file

local filename

Returns
Type Description
\Data from file, or false on failure
methodpublic_validate_offset( \current_row $current_row ) : true

Validates if the row is within the offset or not if sorting is disabled

Parameters
Name Type Description
$current_row \current_row

the current row number being processed

Returns
Type Description
true of false
methodpublic_validate_row_condition( \row $row, \condition $condition ) : true

Validate a row against a single condition

Parameters
Name Type Description
$row \row

array with values from a row

$condition \condition

specified condition that the row must match

Returns
Type Description
true of false
methodpublic_validate_row_conditions( \row $row = array(), \conditions $conditions = null ) : true

Validate a row against specified conditions

Parameters
Name Type Description
$row \row

array with values from a row

$conditions \conditions

specified conditions that the row must match

Returns
Type Description
true of false
methodpublic_wfile( \file $file, string $string = '', \mode $mode = 'wb', \lock $lock = 2 ) : true

Write to local file

Parameters
Name Type Description
$file \file

local filename

$string string

data to write to file

$mode \mode

fopen() mode

$lock \lock

flock() mode

Returns
Type Description
true or false
methodpublicauto( \file $file = null, \parse $parse = true, \search_depth $search_depth = null, \preferred $preferred = null, \enclosure $enclosure = null ) : \delimiter

Auto-Detect Delimiter: Find delimiter by analyzing a specific number of rows to determine most probable delimiter character

Parameters
Name Type Description
$file \file

local CSV file

$parse \parse

true/false parse file directly

$search_depth \search_depth

number of rows to analyze

$preferred \preferred

preferred delimiter characters

$enclosure \enclosure

enclosure character, default is double quote (").

Returns
Type Description
\delimiter character
methodpublicencoding( \input $input = null, \output $output = null ) : \nothing

Convert character encoding

Parameters
Name Type Description
$input \input

input character encoding, uses default if left blank

$output \output

output character encoding, uses default if left blank

Returns
Type Description
\nothing
methodpublicload_data( \input $input = null ) : true

Load local file or string

Parameters
Name Type Description
$input \input

local CSV file

Returns
Type Description
true or false
methodpublicoutput( \filename $filename = null, \data $data = array(), \fields $fields = array(), \delimiter $delimiter = null ) : \CSV

Generate CSV based string for output

Parameters
Name Type Description
$filename \filename

if specified, headers and data will be output directly to browser as a downloable file

$data \data

2D array with data

$fields \fields

field names

$delimiter \delimiter

delimiter used to separate data

Returns
Type Description
\CSV data using delimiter of choice, or default
methodpublicparse( \input $input = null,  $offset = null,  $limit = null,  $conditions = null ) : \nothing

Parse CSV file or string

Parameters
Name Type Description
$input \input

CSV file or string

$offset
$limit
$conditions
Returns
Type Description
\nothing
methodpublicparseCSV( \input $input = null,  $offset = null,  $limit = null,  $conditions = null ) : \nothing

Constructor

Parameters
Name Type Description
$input \input

CSV file or string

$offset
$limit
$conditions
Returns
Type Description
\nothing
methodpublicparse_file( \file $file = null ) : \2D

Read file to string and call parse_string()

Parameters
Name Type Description
$file \file

local CSV file

Returns
Type Description
\2D array with CSV data, or false on failure
methodpublicparse_string( \data $data = null ) : \2D

Parse CSV strings to arrays

Parameters
Name Type Description
$data \data

CSV string

Returns
Type Description
\2D array with CSV data, or false on failure
methodpublicsave( \file $file = null, \data $data = array(), \append $append = false, \fields $fields = array() ) : true

Save changes, or new file and/or data

Parameters
Name Type Description
$file \file

file to save to

$data \data

2D array with data

$append \append

append current data to end of target CSV if exists

$fields \fields

field names

Returns
Type Description
true or false
methodpublicunparse( \data $data = array(), \fields $fields = array(), \append $append = false, \is_php $is_php = false, \delimiter $delimiter = null ) : \CSV

Create CSV data from array

Parameters
Name Type Description
$data \data

2D array with data

$fields \fields

field names

$append \append

if true, field names will not be output

$is_php \is_php

if a php die() call should be put on the first line of the file, this is later ignored when read.

$delimiter \delimiter

field delimiter to use

Returns
Type Description
\CSV data (text string)
Documentation was generated by DocBlox 0.18.1.