PHP Класс parseCSV

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$auto_depth # number of rows to analyze when attempting to auto-detect delimiter
$auto_non_chars # characters to ignore when attempting to auto-detect delimiter
$auto_preferred # returns multiple possible delimiters (happens very rarely)
$conditions # basic SQL-like conditions for row matching
$convert_encoding # character encoding options
$data # two dimentional array of CSV data
$delimiter # delimiter (comma) and enclosure (double quote)
$enclosure
$fields # override field names
$file # current file
$file_data # loaded file contents
$heading # use first line/entry as field names
$input_encoding
$limit # limits the number of returned rows to specified amount
$linefeed # used by unparse(), save(), and output() functions
$offset # number of rows to ignore from beginning of data
$output_delimiter # only used by output() function
$output_encoding
$output_filename
$sort_by # sort entries by this field
$sort_reverse
$titles # array of field values in data parsed

Открытые методы

Метод Описание
__construct ( $input = null, $offset = null, $limit = null, $conditions = null ) : nothing Constructor
_check_count ( $char, $array, $depth, $preferred ) : special Check if passed info might be delimiter - only used by find_delimiter()
_check_data ( $file = null ) : true Check file data
_enclose_value ( $value = null ) : Processed Enclose values if needed - only used by unparse()
_rfile ( $file = null ) : Data Read local file
_validate_offset ( $current_row ) : true Validates if the row is within the offset or not if sorting is disabled
_validate_row_condition ( $row, $condition ) : true Validate a row against a single condition
_validate_row_conditions ( $row = [], $conditions = null ) : true Validate a row against specified conditions
_wfile ( $file, $string = '', $mode = 'wb', $lock = 2 ) : true Write to local file
auto ( $file = null, $parse = true, $search_depth = null, $preferred = null, $enclosure = null ) : delimiter Auto-Detect Delimiter: Find delimiter by analyzing a specific number of rows to determine most probable delimiter character
encoding ( $input = null, $output = null ) : nothing Convert character encoding
load_data ( $input = null ) : true Load local file or string
output ( $output = true, $filename = null, $data = [], $fields = [], $delimiter = null ) : CSV Generate CSV based string for output
parse ( $input = null, $offset = null, $limit = null, $conditions = null ) : nothing Parse CSV file or string
parse_file ( $file = null ) : 2D Read file to string and call parse_string()
parse_string ( $data = null ) : 2D Parse CSV strings to arrays
save ( $file = null, $data = [], $append = false, $fields = [] ) : true Save changes, or new file and/or data
unparse ( $data = [], $fields = [], $append = false, $is_php = false, $delimiter = null ) : CSV Create CSV data from array

Описание методов

__construct() публичный Метод

Constructor
public __construct ( $input = null, $offset = null, $limit = null, $conditions = null ) : nothing
Результат nothing

_check_count() публичный Метод

Check if passed info might be delimiter - only used by find_delimiter()
public _check_count ( $char, $array, $depth, $preferred ) : special
Результат special string used for delimiter selection, or false

_check_data() публичный Метод

Check file data
public _check_data ( $file = null ) : true
Результат true or false

_enclose_value() публичный Метод

Enclose values if needed - only used by unparse()
public _enclose_value ( $value = null ) : Processed
Результат Processed value

_rfile() публичный Метод

Read local file
public _rfile ( $file = null ) : Data
Результат Data from file, or false on failure

_validate_offset() публичный Метод

Validates if the row is within the offset or not if sorting is disabled
public _validate_offset ( $current_row ) : true
Результат true of false

_validate_row_condition() публичный Метод

Validate a row against a single condition
public _validate_row_condition ( $row, $condition ) : true
Результат true of false

_validate_row_conditions() публичный Метод

Validate a row against specified conditions
public _validate_row_conditions ( $row = [], $conditions = null ) : true
Результат true of false

_wfile() публичный Метод

Write to local file
public _wfile ( $file, $string = '', $mode = 'wb', $lock = 2 ) : true
Результат true or false

auto() публичный Метод

Auto-Detect Delimiter: Find delimiter by analyzing a specific number of rows to determine most probable delimiter character
public auto ( $file = null, $parse = true, $search_depth = null, $preferred = null, $enclosure = null ) : delimiter
Результат delimiter character

encoding() публичный Метод

Convert character encoding
public encoding ( $input = null, $output = null ) : nothing
Результат nothing

load_data() публичный Метод

Load local file or string
public load_data ( $input = null ) : true
Результат true or false

output() публичный Метод

Generate CSV based string for output
public output ( $output = true, $filename = null, $data = [], $fields = [], $delimiter = null ) : CSV
Результат CSV data using delimiter of choice, or default

parse() публичный Метод

Parse CSV file or string
public parse ( $input = null, $offset = null, $limit = null, $conditions = null ) : nothing
Результат nothing

parse_file() публичный Метод

Read file to string and call parse_string()
public parse_file ( $file = null ) : 2D
Результат 2D

parse_string() публичный Метод

Parse CSV strings to arrays
public parse_string ( $data = null ) : 2D
Результат 2D

save() публичный Метод

Save changes, or new file and/or data
public save ( $file = null, $data = [], $append = false, $fields = [] ) : true
Результат true or false

unparse() публичный Метод

Create CSV data from array
public unparse ( $data = [], $fields = [], $append = false, $is_php = false, $delimiter = null ) : CSV
Результат CSV data (text string)

Описание свойств

$auto_depth публичное свойство

# number of rows to analyze when attempting to auto-detect delimiter
public $auto_depth

$auto_non_chars публичное свойство

# characters to ignore when attempting to auto-detect delimiter
public $auto_non_chars

$auto_preferred публичное свойство

# returns multiple possible delimiters (happens very rarely)
public $auto_preferred

$conditions публичное свойство

# basic SQL-like conditions for row matching
public $conditions

$convert_encoding публичное свойство

# character encoding options
public $convert_encoding

$data публичное свойство

# two dimentional array of CSV data
public $data

$delimiter публичное свойство

# delimiter (comma) and enclosure (double quote)
public $delimiter

$enclosure публичное свойство

public $enclosure

$fields публичное свойство

# override field names
public $fields

$file публичное свойство

# current file
public $file

$file_data публичное свойство

# loaded file contents
public $file_data

$heading публичное свойство

# use first line/entry as field names
public $heading

$input_encoding публичное свойство

public $input_encoding

$limit публичное свойство

# limits the number of returned rows to specified amount
public $limit

$linefeed публичное свойство

# used by unparse(), save(), and output() functions
public $linefeed

$offset публичное свойство

# number of rows to ignore from beginning of data
public $offset

$output_delimiter публичное свойство

# only used by output() function
public $output_delimiter

$output_encoding публичное свойство

public $output_encoding

$output_filename публичное свойство

public $output_filename

$sort_by публичное свойство

# sort entries by this field
public $sort_by

$sort_reverse публичное свойство

public $sort_reverse

$titles публичное свойство

# array of field values in data parsed
public $titles