PHP 클래스 parseCSV

파일 보기 프로젝트 열기: hillelcoren/invoice-ninja 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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