76 Commits
0.4.0 ... 0.4.5

Author SHA1 Message Date
William Knauss
0486a4bf3e Merge pull request #18 from parsecsv/williamknauss-new-issue-14
williamknauss new issue 14
2014-06-02 20:37:04 -04:00
William Knauss
90042a553c ugh 2014-06-02 20:35:20 -04:00
William Knauss
73d7acb493 fix conflicts 2014-06-02 20:34:08 -04:00
William Knauss
7b6692d7fd @norcoen caching request 2014-06-02 20:13:31 -04:00
William Knauss
01d25e0fdd Tabs to spaces 2014-06-02 20:09:20 -04:00
William Knauss
c64a4bffd7 Merge pull request #12 from williamknauss/tab_to_spaces
Fix #11
2014-05-17 12:51:24 -04:00
William Knauss
2d7f18ebc9 converted tabs to spaces 2014-05-17 12:47:45 -04:00
William Knauss
ee5b34e1c1 Merge branch 'master' of https://github.com/parsecsv/parsecsv-for-php 2014-05-17 12:43:00 -04:00
William Knauss
44929708ca Merge pull request #10 from parsecsv/fix-author-name-spelling
Fix typo in author name
2014-05-17 12:41:36 -04:00
c55ab2ec2c Fix typo in author's last name 2014-05-17 10:50:01 +01:00
William Knauss
6784c614ea Merge pull request #2 from parsecsv/master
Fork Update
2014-05-16 19:49:55 -04:00
William Knauss
5a70a7bffa Merge pull request #9 from williamknauss/composer-support
Composer support
2014-05-16 19:37:46 -04:00
William Knauss
c1a6946815 added gitignore 2014-05-16 19:33:15 -04:00
William Knauss
dbf415bd92 Added Composer.json 2014-05-16 19:30:59 -04:00
William Knauss
c915579955 Merge pull request #8 from williamknauss/readme_update-1
Readme update
2014-05-16 17:36:59 -04:00
William Knauss
55aaa1eb17 Grammer Fix 2014-05-16 17:36:14 -04:00
William Knauss
ab069e5d2d Updated readme 2014-05-16 17:35:08 -04:00
William Knauss
7e7aeba761 Merge pull request #6 from williamknauss/issue-5
Issue 5
2014-05-14 10:29:48 -04:00
William Knauss
a3e3582222 Patch for #5 2014-05-14 10:26:32 -04:00
William Knauss
fff3e73f08 Merge pull request #1 from parsecsv/master
U2D
2014-05-14 10:20:18 -04:00
f59af53183 Add contributors section to readme 2014-05-14 14:50:10 +01:00
629b0c9fd5 Indent header comment start/end strings 2014-05-14 10:18:02 +01:00
698a570a11 Add license header 2014-05-14 10:12:45 +01:00
2aca09e05d Add URL to PHP class which inspired parseCSV's creation 2014-05-14 09:26:21 +01:00
7a9fc101f8 Update copyright year in readme and license file 2014-05-14 09:24:27 +01:00
a1564a9a99 Correct project URL, and update copyright 2014-05-14 09:19:42 +01:00
4b280885f4 Merge pull request #1 from williamknauss/master
Basic Cleanup
2014-05-14 09:14:26 +01:00
William Knauss
88ad81f061 removed end of php line
its not really needed
2014-05-13 21:26:06 -04:00
William Knauss
7e46cc193a line feed should only be \r 2014-05-13 21:23:53 -04:00
William Knauss
a274874084 documenation changes 2014-05-13 21:23:23 -04:00
William Knauss
dea1b453eb _validate_row_conditions readability 2014-05-13 21:21:58 -04:00
William Knauss
9a8bd77eb8 forgot access flag 2014-05-13 21:21:04 -04:00
William Knauss
89a2817765 _validate_row_condition readability 2014-05-13 21:19:44 -04:00
William Knauss
75d7d51a9c _validate_offset readability 2014-05-13 21:05:53 -04:00
William Knauss
9b6dbd9849 _enclose_value readability 2014-05-13 21:05:11 -04:00
William Knauss
61d1c27eac _check_data readability 2014-05-13 21:04:25 -04:00
William Knauss
ecbb0736f1 more changes 2014-05-13 18:56:26 -04:00
William Knauss
2ab7625bb5 _rfile readability 2014-05-13 18:24:31 -04:00
William Knauss
0f39cfa75a _wfile readability 2014-05-13 18:23:27 -04:00
William Knauss
0457fbfba2 removed back comments 2014-05-13 18:22:18 -04:00
William Knauss
af5d7cf70d load_data readability 2014-05-09 21:57:17 -04:00
William Knauss
531cc66a5e unparse readability 2014-05-09 21:55:54 -04:00
William Knauss
178699580e unparse readability 2014-05-09 21:55:36 -04:00
William Knauss
8c300568bb parse_string readability 2014-05-09 21:54:09 -04:00
William Knauss
28967dea20 extra space 2014-05-09 21:46:11 -04:00
William Knauss
46b42776e4 Properties documentation 2014-05-09 21:45:03 -04:00
William Knauss
8ba88c582d removed documentation whitespace 2014-05-09 21:31:22 -04:00
William Knauss
ba1d462044 updated properties to "public"
removed "var" and set to "public"
2014-05-09 21:30:47 -04:00
William Knauss
0323d5108b parse_file documentation 2014-02-06 18:31:34 -05:00
William Knauss
2988278f0b parse_file readability 2014-02-06 18:30:43 -05:00
William Knauss
9301b016c8 auto documentation 2014-02-06 18:30:11 -05:00
William Knauss
75038f9d2f auto readability 2014-02-06 18:27:54 -05:00
William Knauss
b72385395e condition spacing 2014-02-06 08:17:00 -05:00
William Knauss
eb3c9faa4a construct docblock spacing 2014-02-05 19:16:51 -05:00
William Knauss
2f142e7313 public encoding 2014-02-05 19:16:35 -05:00
William Knauss
05dbcaf652 encoding update 2014-02-05 19:14:00 -05:00
William Knauss
4639fa1701 Output documentation 2014-02-05 19:12:16 -05:00
William Knauss
8bb8e2d7cf output readability 2014-02-05 19:09:57 -05:00
William Knauss
c7e1f825a0 save documentation 2014-02-05 18:41:21 -05:00
William Knauss
0638049fb2 save readability 2014-02-05 18:38:55 -05:00
William Knauss
585a0d472e parse documentation 2014-02-05 18:37:23 -05:00
William Knauss
d6a070ce08 Change __constructor docblock stype 2014-02-05 18:33:44 -05:00
William Knauss
4454196b4c parse readability 2014-02-05 18:31:27 -05:00
William Knauss
6a6754ca04 __construct documentation 2014-02-05 18:29:01 -05:00
William Knauss
8dd2e52073 __construct readability 2014-02-05 18:25:13 -05:00
William Knauss
e16d818d07 cleaned up construct 2014-02-05 18:24:41 -05:00
William Knauss
9e6fdbb42a Updated project link 2014-02-05 18:22:20 -05:00
85ca7af160 Update License.txt file 2014-02-05 21:18:07 +00:00
1b91591d32 Add readme 2014-02-05 21:16:50 +00:00
zynode
dfe298f4d0 Fixed a typo in the header comment regarding example code.
git-svn-id: http://parsecsv-for-php.googlecode.com/svn/trunk@44 339761fc-0c37-0410-822d-8b8cac1f6a97
2008-11-17 15:48:46 +00:00
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
zynode
0395362d66 parseCSV 0.4.2
git-svn-id: http://parsecsv-for-php.googlecode.com/svn/trunk@34 339761fc-0c37-0410-822d-8b8cac1f6a97
2008-05-31 17:59:21 +00:00
zynode
20a6a9d1b1 parseCSV 0.4.1 beta
git-svn-id: http://parsecsv-for-php.googlecode.com/svn/trunk@31 339761fc-0c37-0410-822d-8b8cac1f6a97
2008-05-30 12:20:39 +00:00
7 changed files with 1400 additions and 750 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
vendor/
composer.lock

View File

@@ -1,3 +1,54 @@
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(),
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 :)
- Small fix to the headers sent by the output()
method.
- Added a download example using the output()
method to the examples folder.
-----------------------------------
parseCSV 0.4.1 beta
-----------------------------------
Date: 29-May-2008
- Fixed a small bug in how the output() method
handles input data.
-----------------------------------
parseCSV 0.4 beta
-----------------------------------
Date: 11-Apr-2008

View File

@@ -1,4 +1,6 @@
Copyright (c) 2007 Jim Myhrberg (jim@zydev.info).
(The MIT license)
Copyright (c) 2014 Jim Myhrberg.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -7,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

129
README.md Normal file
View File

@@ -0,0 +1,129 @@
# parseCSV
Note: parseCSV is now being revised to PHP 5 standards. If you have an issue or a feature request we encourage you to open an issue.
parseCSV is an easy to use PHP class that reads and writes CSV data properly. It
fully conforms to the specifications outlined on the on the
[Wikipedia article][CSV]. It has many advanced features which help make your
life easier when dealing with CSV data.
This library was originaly created in early 2007 by [jimeh](https://github.com/jimeh) due to the lack of built-in
and third-party support for handling CSV data in PHP.
[csv]: http://en.wikipedia.org/wiki/Comma-separated_values
## Features
* parseCSV is the only complete and fully featured CSV solution for PHP (as
far as I know).
* Supports enclosed values, enclosed commas, double quotes and new lines.
* Automatic delimiter character detection.
* Sort data by specific fields/columns.
* Easy data manipulation.
* Basic SQL-like _conditions_, _offset_ and _limit_ options for filtering
data.
* Error detection for incorrectly formatted input. It attempts to be
intelligent, but can not be trusted 100% due to the structure of CSV, and
how different programs like Excel for example outputs CSV data.
* Support for character encoding conversion using PHP's _iconv_ function
(requires PHP 5).
* Supports both PHP 4 & 5.
## Example Usage
**General**
```php
$csv = new parseCSV('data.csv');
print_r($csv->data);
```
**Tab delimited, and encoding conversion**
```php
$csv = new parseCSV();
$csv->encoding('UTF-16', 'UTF-8');
$csv->delimiter = "\t";
$csv->parse('data.tsv');
print_r($csv->data);
```
**Auto-detect delimiter character**
```php
$csv = new parseCSV();
$csv->auto('data.csv');
print_r($csv->data);
```
**Modify data in a CSV file**
```php
$csv = new parseCSV();
$csv->sort_by = 'id';
$csv->parse('data.csv');
# "4" is the value of the "id" column of the CSV row
$csv->data[4] = array('firstname' => 'John', 'lastname' => 'Doe', 'email' => 'john@doe.com');
$csv->save();
```
**Add row/entry to end of CSV file**
_Only recommended when you know the extact sctructure of the file._
```php
$csv = new parseCSV();
$csv->save('data.csv', array('1986', 'Home', 'Nowhere', ''), true);
```
**Convert 2D array to csv data and send headers to browser to treat output as
a file and download it**
```php
$csv = new parseCSV();
$csv->output('movies.csv', $array, array('field 1', 'field 2'), ',');
```
## Credits
* parseCSV is based on the concept of [Ming Hong Ng][ming]'s [CsvFileParser][]
class.
[ming]: http://minghong.blogspot.com/
[CsvFileParser]: http://minghong.blogspot.com/2006/07/csv-parser-for-php.html
## Contributors
Please find a complete list on the project's [contributors][] page.
[contributors]: https://github.com/parsecsv/parsecsv-for-php/graphs/contributors
## License
(The MIT license)
Copyright (c) 2014 Jim Myhrberg.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

17
composer.json Normal file
View File

@@ -0,0 +1,17 @@
{
"name": "parsecsv/php-parsecsv",
"description": "CSV data parser for PHP",
"license": "MIT",
"authors": [
{
"name": "Jim Myhrberg",
"email": "contact@jimeh.me"
}
],
"autoload": {
"classmap": ["."]
},
"require-dev": {
"phpunit/phpunit": "4.1.*"
}
}

34
examples/download.php Normal file
View File

@@ -0,0 +1,34 @@
<?php
# include parseCSV class.
require_once('../parsecsv.lib.php');
# create new parseCSV object.
$csv = new parseCSV();
# Parse '_books.csv' using automatic delimiter detection...
$csv->auto('_books.csv');
# ...or if you know the delimiter, set the delimiter character
# if its not the default comma...
// $csv->delimiter = "\t"; # tab delimited
# ...and then use the parse() function.
// $csv->parse('_books.csv');
# now we have data in $csv->data, at which point we can modify
# it to our hearts content, like removing the last item...
array_pop($csv->data);
# then we output the file to the browser as a downloadable file...
$csv->output('books.csv');
# ...when the first parameter is given and is not null, the
# output method will itself send the correct headers and the
# data to download the output as a CSV file. if it's not set
# or is set to null, output will only return the generated CSV
# output data, and will not output to the browser itself.
?>

File diff suppressed because it is too large Load Diff