4 Commits
0.4.2 ... 0.4.3

Author SHA1 Message Date
zynode
fc22bee7ca parseCSV 0.4.3 beta
- Issue #4. Added an option for setting sorting
  type behavior when sorting data.
  Simply set $csv->sort_type to "regular", "numeric",
  or "string".

- Issue #6. Raw loaded file data is now cleared from
  file_data property when it has been successfully
  parsed to keep parseCSV's memory footprint to a
  minimum. Specifically handy when using mulitple
  instances of parseCSV to process large files.

git-svn-id: http://parsecsv-for-php.googlecode.com/svn/trunk@41 339761fc-0c37-0410-822d-8b8cac1f6a97
2008-06-30 21:41:42 +00:00
zynode
9b64cb07c4 Fixed Issue #6 - Automatically clears $file_data property after successful parsing of input data. Set the $keep_file_data property to true to keep it around for debugging.
git-svn-id: http://parsecsv-for-php.googlecode.com/svn/trunk@39 339761fc-0c37-0410-822d-8b8cac1f6a97
2008-06-30 20:38:59 +00:00
zynode
2bfa3de220 Addressed Issue #4. Added option for sorting behavior type.
git-svn-id: http://parsecsv-for-php.googlecode.com/svn/trunk@38 339761fc-0c37-0410-822d-8b8cac1f6a97
2008-06-30 20:01:50 +00:00
zynode
c522cd87a7 fixed a small changelog typo in the 0.4.2 trunk and tag
git-svn-id: http://parsecsv-for-php.googlecode.com/svn/trunk@36 339761fc-0c37-0410-822d-8b8cac1f6a97
2008-05-31 18:12:15 +00:00
2 changed files with 42 additions and 7 deletions

View File

@@ -1,13 +1,31 @@
parseCSV 0.4.3 beta
-----------------------------------
Date: 1-July-2008
- Issue #4. Added an option for setting sorting
type behavior when sorting data.
Simply set $csv->sort_type to "regular", "numeric",
or "string".
- Issue #6. Raw loaded file data is now cleared from
file_data property when it has been successfully
parsed to keep parseCSV's memory footprint to a
minimum. Specifically handy when using mulitple
instances of parseCSV to process large files.
-----------------------------------
parseCSV 0.4.2 beta
-----------------------------------
Date: 31-May-2008
- IMPORTANT! If you're using the output(),
please note that the first parameter has been
completely removed as it was technically just
useless. Instead, the second parameter
(filename) doubles as its replacement. Simply
put, if filename is not set or null, the
method please note that the first parameter
has been completely removed as it was
technically just useless. Instead, the second
parameter (filename) doubles as its replacement.
Simply put, if filename is not set or null, the
output() method will not output a downloadable
file. Please update your existing code
when using 0.4.2 and later :)

View File

@@ -4,7 +4,7 @@ class parseCSV {
/*
Class: parseCSV v0.4.2 beta
Class: parseCSV v0.4.3 beta
http://code.google.com/p/parsecsv-for-php/
@@ -94,6 +94,12 @@ class parseCSV {
var $sort_by = null;
var $sort_reverse = false;
# sort behavior passed to ksort/krsort functions
# regular = SORT_REGULAR
# numeric = SORT_NUMERIC
# string = SORT_STRING
var $sort_type = null;
# delimiter (comma) and enclosure (double quote)
var $delimiter = ',';
var $enclosure = '"';
@@ -129,6 +135,8 @@ class parseCSV {
var $output_delimiter = ',';
var $output_filename = 'data.csv';
# keep raw file data in memory after successful parsing (useful for debugging)
var $keep_file_data = false;
/**
* Internal variables
@@ -473,11 +481,20 @@ class parseCSV {
}
$this->titles = $head;
if ( !empty($this->sort_by) ) {
( $this->sort_reverse ) ? krsort($rows) : ksort($rows) ;
$sort_type = SORT_REGULAR;
if ( $this->sort_type == 'numeric' ) {
$sort_type = SORT_NUMERIC;
} elseif ( $this->sort_type == 'string' ) {
$sort_type = SORT_STRING;
}
( $this->sort_reverse ) ? krsort($rows, $sort_type) : ksort($rows, $sort_type) ;
if ( $this->offset !== null || $this->limit !== null ) {
$rows = array_slice($rows, ($this->offset === null ? 0 : $this->offset) , $this->limit, true);
}
}
if ( !$this->keep_file_data ) {
$this->file_data = null;
}
return $rows;
}