include/parsecsv.lib.php
\parseCSV
Properties

$heading= 'true'
Configuration - set these options with $object->var_name = 'value';
trueDetails- Type
- n/a
Methods

_check_count(
$char, $array, $depth, $preferred
)
:
\specialCheck if passed info might be delimiter - only used by find_delimiter()
| Name | Type | Description |
|---|---|---|
| $char | ||
| $array | ||
| $depth | ||
| $preferred |
| Type | Description |
|---|---|
| \special | string used for delimiter selection, or false |

_check_data(
\file $file
=
null
)
:
trueCheck file data
| Name | Type | Description |
|---|---|---|
| $file | \file | local filename |
| Type | Description |
|---|---|
| true | or false |

_enclose_value(
\value $value
=
null
)
:
\ProcessedEnclose values if needed - only used by unparse()
| Name | Type | Description |
|---|---|---|
| $value | \value | string to process |
| Type | Description |
|---|---|
| \Processed | value |

_rfile(
\file $file
=
null
)
:
\DataRead local file
| Name | Type | Description |
|---|---|---|
| $file | \file | local filename |
| Type | Description |
|---|---|
| \Data | from file, or false on failure |

_validate_offset(
\current_row $current_row
)
:
trueValidates if the row is within the offset or not if sorting is disabled
| Name | Type | Description |
|---|---|---|
| $current_row | \current_row | the current row number being processed |
| Type | Description |
|---|---|
| true | of false |

_validate_row_condition(
\row $row, \condition $condition
)
:
trueValidate a row against a single condition
| Name | Type | Description |
|---|---|---|
| $row | \row | array with values from a row |
| $condition | \condition | specified condition that the row must match |
| Type | Description |
|---|---|
| true | of false |

_validate_row_conditions(
\row $row
=
array(), \conditions $conditions
=
null
)
:
trueValidate a row against specified conditions
| Name | Type | Description |
|---|---|---|
| $row | \row | array with values from a row |
| $conditions | \conditions | specified conditions that the row must match |
| Type | Description |
|---|---|
| true | of false |

_wfile(
\file $file, string $string
=
'', \mode $mode
=
'wb', \lock $lock
=
2
)
:
trueWrite to local file
| Name | Type | Description |
|---|---|---|
| $file | \file | local filename |
| $string | string | data to write to file |
| $mode | \mode | fopen() mode |
| $lock | \lock | flock() mode |
| Type | Description |
|---|---|
| true | or false |

auto(
\file $file
=
null, \parse $parse
=
true, \search_depth $search_depth
=
null, \preferred $preferred
=
null, \enclosure $enclosure
=
null
)
:
\delimiterAuto-Detect Delimiter: Find delimiter by analyzing a specific number of rows to determine most probable delimiter character
| 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 ("). |
| Type | Description |
|---|---|
| \delimiter | character |

encoding(
\input $input
=
null, \output $output
=
null
)
:
\nothingConvert character encoding
| Name | Type | Description |
|---|---|---|
| $input | \input | input character encoding, uses default if left blank |
| $output | \output | output character encoding, uses default if left blank |
| Type | Description |
|---|---|
| \nothing |

load_data(
\input $input
=
null
)
:
trueLoad local file or string
| Name | Type | Description |
|---|---|---|
| $input | \input | local CSV file |
| Type | Description |
|---|---|
| true | or false |

output(
\filename $filename
=
null, \data $data
=
array(), \fields $fields
=
array(), \delimiter $delimiter
=
null
)
:
\CSVGenerate CSV based string for output
| 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 |
| Type | Description |
|---|---|
| \CSV | data using delimiter of choice, or default |

parse(
\input $input
=
null, $offset
=
null, $limit
=
null, $conditions
=
null
)
:
\nothingParse CSV file or string
| Name | Type | Description |
|---|---|---|
| $input | \input | CSV file or string |
| $offset | ||
| $limit | ||
| $conditions |
| Type | Description |
|---|---|
| \nothing |

parseCSV(
\input $input
=
null, $offset
=
null, $limit
=
null, $conditions
=
null
)
:
\nothingConstructor
| Name | Type | Description |
|---|---|---|
| $input | \input | CSV file or string |
| $offset | ||
| $limit | ||
| $conditions |
| Type | Description |
|---|---|
| \nothing |

parse_file(
\file $file
=
null
)
:
\2DRead file to string and call parse_string()
| Name | Type | Description |
|---|---|---|
| $file | \file | local CSV file |
| Type | Description |
|---|---|
| \2D | array with CSV data, or false on failure |

parse_string(
\data $data
=
null
)
:
\2DParse CSV strings to arrays
| Name | Type | Description |
|---|---|---|
| $data | \data | CSV string |
| Type | Description |
|---|---|
| \2D | array with CSV data, or false on failure |

save(
\file $file
=
null, \data $data
=
array(), \append $append
=
false, \fields $fields
=
array()
)
:
trueSave changes, or new file and/or data
| 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 |
| Type | Description |
|---|---|
| true | or false |

unparse(
\data $data
=
array(), \fields $fields
=
array(), \append $append
=
false, \is_php $is_php
=
false, \delimiter $delimiter
=
null
)
:
\CSVCreate CSV data from array
| 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 |
| Type | Description |
|---|---|
| \CSV | data (text string) |