mirror of
https://github.com/parsecsv/parsecsv-for-php.git
synced 2026-02-19 08:36:39 +00:00
Properties documentation
This commit is contained in:
233
parsecsv.lib.php
233
parsecsv.lib.php
@@ -70,93 +70,260 @@ class parseCSV {
|
|||||||
----------------
|
----------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration
|
* Configuration
|
||||||
* - set these options with $object->var_name = 'value';
|
* - set these options with $object->var_name = 'value';
|
||||||
*/
|
*/
|
||||||
|
|
||||||
# use first line/entry as field names
|
/**
|
||||||
|
* Heading
|
||||||
|
* Use first line/entry as field names
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
public $heading = true;
|
public $heading = true;
|
||||||
|
|
||||||
# override field names
|
/**
|
||||||
|
* Fields
|
||||||
|
* Override field names
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
public $fields = array();
|
public $fields = array();
|
||||||
|
|
||||||
# sort entries by this field
|
/**
|
||||||
|
* Sort By
|
||||||
|
* Sort csv by this field
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $sort_by = null;
|
public $sort_by = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort Reverse
|
||||||
|
* Reverse the sort function
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
public $sort_reverse = false;
|
public $sort_reverse = false;
|
||||||
|
|
||||||
# sort behavior passed to ksort/krsort functions
|
/**
|
||||||
# regular = SORT_REGULAR
|
* Sort Type
|
||||||
# numeric = SORT_NUMERIC
|
* Sort behavior passed to sort methods
|
||||||
# string = SORT_STRING
|
*
|
||||||
|
* regular = SORT_REGULAR
|
||||||
|
* numeric = SORT_NUMERIC
|
||||||
|
* string = SORT_STRING
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $sort_type = null;
|
public $sort_type = null;
|
||||||
|
|
||||||
# delimiter (comma) and enclosure (double quote)
|
/**
|
||||||
|
* Delimiter
|
||||||
|
* Delimiter character
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $delimiter = ',';
|
public $delimiter = ',';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enclosure
|
||||||
|
* Enclosure character
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $enclosure = '"';
|
public $enclosure = '"';
|
||||||
|
|
||||||
# basic SQL-like conditions for row matching
|
/**
|
||||||
|
* Conditions
|
||||||
|
* Basic SQL-Like conditions for row matching
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $conditions = null;
|
public $conditions = null;
|
||||||
|
|
||||||
# number of rows to ignore from beginning of data
|
/**
|
||||||
|
* Offset
|
||||||
|
* Number of rows to ignore from beginning of data
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
public $offset = null;
|
public $offset = null;
|
||||||
|
|
||||||
# limits the number of returned rows to specified amount
|
/**
|
||||||
|
* Limit
|
||||||
|
* Limits the number of returned rows to the specified amount
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
public $limit = null;
|
public $limit = null;
|
||||||
|
|
||||||
# number of rows to analyze when attempting to auto-detect delimiter
|
/**
|
||||||
|
* Auto Depth
|
||||||
|
* Number of rows to analyze when attempting to auto-detect delimiter
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
public $auto_depth = 15;
|
public $auto_depth = 15;
|
||||||
|
|
||||||
# characters to ignore when attempting to auto-detect delimiter
|
/**
|
||||||
|
* Auto Non Charts
|
||||||
|
* Characters that should be ignored when attempting to auto-detect delimiter
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $auto_non_chars = "a-zA-Z0-9\n\r";
|
public $auto_non_chars = "a-zA-Z0-9\n\r";
|
||||||
|
|
||||||
# preferred delimiter characters, only used when all filtering method
|
/**
|
||||||
# returns multiple possible delimiters (happens very rarely)
|
* Auto Preferred
|
||||||
|
* preferred delimiter characters, only used when all filtering method
|
||||||
|
* returns multiple possible delimiters (happens very rarely)
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $auto_preferred = ",;\t.:|";
|
public $auto_preferred = ",;\t.:|";
|
||||||
|
|
||||||
# character encoding options
|
/**
|
||||||
|
* Convert Encoding
|
||||||
|
* Should we convert the csv encoding?
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
public $convert_encoding = false;
|
public $convert_encoding = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Input Encoding
|
||||||
|
* Set the input encoding
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $input_encoding = 'ISO-8859-1';
|
public $input_encoding = 'ISO-8859-1';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output Encoding
|
||||||
|
* Set the output encoding
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $output_encoding = 'ISO-8859-1';
|
public $output_encoding = 'ISO-8859-1';
|
||||||
|
|
||||||
# used by unparse(), save(), and output() functions
|
/**
|
||||||
|
* Linefeed
|
||||||
|
* Line feed characters used by unparse, save, and output methods
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $linefeed = "\r\n";
|
public $linefeed = "\r\n";
|
||||||
|
|
||||||
# only used by output() function
|
/**
|
||||||
|
* Output Delimiter
|
||||||
|
* Sets the output delimiter used by the output method
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $output_delimiter = ',';
|
public $output_delimiter = ',';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output filename
|
||||||
|
* Sets the output filename
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $output_filename = 'data.csv';
|
public $output_filename = 'data.csv';
|
||||||
|
|
||||||
# keep raw file data in memory after successful parsing (useful for debugging)
|
/**
|
||||||
|
* Keep File Data
|
||||||
|
* keep raw file data in memory after successful parsing (useful for debugging)
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
public $keep_file_data = false;
|
public $keep_file_data = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal variables
|
* Internal variables
|
||||||
*/
|
*/
|
||||||
|
|
||||||
# current file
|
/**
|
||||||
|
* File
|
||||||
|
* Current Filename
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $file;
|
public $file;
|
||||||
|
|
||||||
# loaded file contents
|
/**
|
||||||
|
* File Data
|
||||||
|
* Current file data
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $file_data;
|
public $file_data;
|
||||||
|
|
||||||
# error while parsing input data
|
/**
|
||||||
# 0 = No errors found. Everything should be fine :)
|
* Error
|
||||||
# 1 = Hopefully correctable syntax error was found.
|
* Contains the error code if one occured
|
||||||
# 2 = Enclosure character (double quote by default)
|
*
|
||||||
# was found in non-enclosed field. This means
|
* 0 = No errors found. Everything should be fine :)
|
||||||
# the file is either corrupt, or does not
|
* 1 = Hopefully correctable syntax error was found.
|
||||||
# standard CSV formatting. Please validate
|
* 2 = Enclosure character (double quote by default)
|
||||||
# the parsed data yourself.
|
* was found in non-enclosed field. This means
|
||||||
|
* the file is either corrupt, or does not
|
||||||
|
* standard CSV formatting. Please validate
|
||||||
|
* the parsed data yourself.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
public $error = 0;
|
public $error = 0;
|
||||||
|
|
||||||
# detailed error info
|
/**
|
||||||
|
* Error Information
|
||||||
|
* Detailed error information
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
public $error_info = array();
|
public $error_info = array();
|
||||||
|
|
||||||
# array of field values in data parsed
|
/**
|
||||||
|
* Titles
|
||||||
|
* CSV titles if they exists
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
public $titles = array();
|
public $titles = array();
|
||||||
|
|
||||||
# two dimentional array of CSV data
|
/**
|
||||||
|
* Data
|
||||||
|
* Two dimensional array of CSV data
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
public $data = array();
|
public $data = array();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user