# ParseCsv
[![Financial Contributors on Open Collective](https://opencollective.com/parsecsv/all/badge.svg?label=financial+contributors)](https://opencollective.com/parsecsv)
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] (and thus RFC 4180). It has many advanced features which help make your
life easier when dealing with CSV data.
You may not need a library at all: before using ParseCsv, please make sure if PHP's own `str_getcsv()`, ``fgetcvs()`` or `fputcsv()` meets your needs.
This library was originally 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 a complete and fully featured CSV solution for PHP
* 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()` and `mb_convert_encoding()` functions.
* Supports PHP 5.5 and higher.
It certainly works with PHP 7.2 and all versions in between.
## Installation
Installation is easy using Composer. Just run the following on the
command line:
```
composer require parsecsv/php-parsecsv
```
If you don't use a framework such as Drupal, Laravel, Symfony, Yii etc.,
you may have to manually include Composer's autoloader file in your PHP
script:
```php
require_once __DIR__ . '/vendor/autoload.php';
```
#### Without composer
Not recommended, but technically possible: you can also clone the
repository or extract the
[ZIP](https://github.com/parsecsv/parsecsv-for-php/archive/master.zip).
To use ParseCSV, you then have to add a `require 'parsecsv.lib.php';` line.
## Example Usage
**General**
```php
$csv = new ParseCsv\Csv('data.csv');
print_r($csv->data);
```
**Tab delimited, and encoding conversion**
```php
$csv = new ParseCsv\Csv();
$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();
$csv->auto('data.csv');
print_r($csv->data);
```
**Parse data with offset**
* ignoring the first X (e.g. two) rows
```php
$csv = new ParseCsv\Csv();
$csv->offset = 2;
$csv->parse('data.csv');
print_r($csv->data);
```
**Limit the number of returned data rows**
```php
$csv = new ParseCsv\Csv();
$csv->limit = 5;
$csv->parse('data.csv');
print_r($csv->data);
```
**Get total number of data rows without parsing whole data**
* Excluding heading line if present (see $csv->header property)
```php
$csv = new ParseCsv\Csv();
$csv->load_data('data.csv');
$count = $csv->getTotalDataRowCount();
print_r($count);
```
**Get most common data type for each column**
```php
$csv = new ParseCsv\Csv('data.csv');
$csv->getDatatypes()
print_r($csv->data_types);
```
**Modify data in a CSV file**
Change data values:
```php
$csv = new ParseCsv\Csv();
$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();
```
Enclose each data value by quotes:
```php
$csv = new ParseCsv\Csv();
$csv->parse('data.csv');
$csv->enclose_all = true;
$csv->save();
```
**Replace field names or set ones if missing**
```php
$csv = new ParseCsv\Csv();
$csv->fields = ['id', 'name', 'category']
$csv->parse('data.csv');
```
**Add row/entry to end of CSV file**
_Only recommended when you know the exact structure of the file._
```php
$csv = new ParseCsv\Csv();
$csv->save('data.csv', array(array('1986', 'Home', 'Nowhere', '')), /* append */ 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();
$csv->output('movies.csv', $array, array('field 1', 'field 2'), ',');
```
For more complex examples, see the ``tests`` and `examples` directories.
## 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
### Code Contributors
This project exists thanks to all the people who contribute.
Please find a complete list on the project's [contributors][] page.
[contributors]: https://github.com/parsecsv/parsecsv-for-php/graphs/contributors
<a href="https://github.com/parsecsv/parsecsv-for-php/graphs/contributors"><img src="https://opencollective.com/parsecsv/contributors.svg?width=890&button=false" /></a>
### Financial Contributors
Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/parsecsv/contribute)]
#### Individuals
<a href="https://opencollective.com/parsecsv"><img src="https://opencollective.com/parsecsv/individuals.svg?width=890"></a>
#### Organizations
Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/parsecsv/contribute)]
<a href="https://opencollective.com/parsecsv/organization/0/website"><img src="https://opencollective.com/parsecsv/organization/0/avatar.svg"></a>
<a href="https://opencollective.com/parsecsv/organization/1/website"><img src="https://opencollective.com/parsecsv/organization/1/avatar.svg"></a>
<a href="https://opencollective.com/parsecsv/organization/2/website"><img src="https://opencollective.com/parsecsv/organization/2/avatar.svg"></a>
<a href="https://opencollective.com/parsecsv/organization/3/website"><img src="https://opencollective.com/parsecsv/organization/3/avatar.svg"></a>
<a href="https://opencollective.com/parsecsv/organization/4/website"><img src="https://opencollective.com/parsecsv/organization/4/avatar.svg"></a>
<a href="https://opencollective.com/parsecsv/organization/5/website"><img src="https://opencollective.com/parsecsv/organization/5/avatar.svg"></a>
<a href="https://opencollective.com/parsecsv/organization/6/website"><img src="https://opencollective.com/parsecsv/organization/6/avatar.svg"></a>
<a href="https://opencollective.com/parsecsv/organization/7/website"><img src="https://opencollective.com/parsecsv/organization/7/avatar.svg"></a>
<a href="https://opencollective.com/parsecsv/organization/8/website"><img src="https://opencollective.com/parsecsv/organization/8/avatar.svg"></a>
<a href="https://opencollective.com/parsecsv/organization/9/website"><img src="https://opencollective.com/parsecsv/organization/9/avatar.svg"></a>
## 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 CONT
没有合适的资源?快使用搜索试试~ 我知道了~
【WordPress插件】2022年最新版完整功能demo+插件v2.4.3.zip
共224个文件
php:147个
js:18个
csv:12个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 183 浏览量
2022-04-05
14:19:17
上传
评论
收藏 367KB ZIP 举报
温馨提示
"【WordPress插件】2022年最新版完整功能demo+插件v2.4.3 Pinterest for WooCommerce Woocommerce的Pinterest" ---------- 泰森云每天更新发布最新WordPress主题、HTML主题、WordPress插件、shopify主题、opencart主题、PHP项目源码、安卓项目源码、ios项目源码,更有超10000个资源可供选择,如有需要请站内联系。
资源推荐
资源详情
资源评论
收起资源包目录
【WordPress插件】2022年最新版完整功能demo+插件v2.4.3.zip (224个子文件)
pins.css 3KB
product.css 3KB
pins.min.css 3KB
product.min.css 2KB
pinit.css 699B
products-table.css 683B
products-table.min.css 616B
pinit.min.css 537B
primary-category.css 128B
google_catalog.csv 429KB
Piwik_API_download.csv 69KB
multiple_empty_lines.csv 2KB
_books.csv 1KB
UTF-16LE_with_BOM_and_sep_row.csv 326B
datatype.csv 234B
UTF-8_with_BOM_and_sep_row.csv 178B
UTF-8_sep_row_but_no_BOM.csv 175B
waiver_field_separator.csv 105B
auto-single-enclosure.csv 55B
auto-double-enclosure.csv 55B
single_column.csv 23B
.DS_Store 6KB
.DS_Store 6KB
.editorconfig 320B
.gitignore 53B
.gitignore 13B
.gitignore 7B
settings.js 13KB
settings.min.js 7KB
product.js 6KB
product.min.js 3KB
primary-category.js 2KB
pinit.js 2KB
track-add-to-cart.js 1KB
terms-pages.js 971B
pinit.min.js 898B
pinterest-analytics-init.js 790B
gulpfile.js 788B
terms-pages.min.js 675B
track-add-to-cart.min.js 597B
pinterest-analytics-init.min.js 413B
pins.js 180B
pins.min.js 147B
products-table.js 88B
products-table.min.js 75B
package-lock.json 127KB
installed.json 4KB
composer.json 1KB
composer.json 803B
composer.json 476B
composer.json 341B
package.json 175B
LICENSE 3KB
composer.lock 19KB
Makefile 326B
README.md 8KB
readme.md 3KB
readme.md 3KB
README.md 2KB
en_US.mo 662B
premmerce-primary-category-ru_RU.mo 618B
premmerce-primary-category-uk_UA.mo 542B
woocommerce-pinterest.mo 539B
Csv.php 45KB
PinterestIntegration.php 26KB
ServiceContainer.php 18KB
ProductHandler.php 17KB
PinService.php 15KB
PinsTable.php 14KB
ClassLoader.php 13KB
PinDataGenerator.php 13KB
PinModel.php 11KB
AbstractModel.php 11KB
Admin.php 10KB
ParseTest.php 10KB
metabox.php 10KB
Api.php 9KB
GeneralSettingsSection.php 9KB
CatalogGenerator.php 9KB
AdminAssets.php 8KB
AjaxController.php 8KB
CatalogGenerationTaskManager.php 7KB
PinTimeSection.php 7KB
BoardRelationsModel.php 7KB
PinterestTagsRepository.php 7KB
Frontend.php 6KB
PinCreationBackgroundProcess.php 6KB
WcCategoryGoogleCategoryRelationsTable.php 6KB
Installer.php 6KB
Pins.php 6KB
PinAllManager.php 6KB
PinterestTagsController.php 5KB
BoardCreationBackgroundProcess.php 5KB
GoogleCategoriesRelationsModel.php 5KB
Analytics.php 5KB
TermsCollection.php 5KB
GoogleCategoriesImporter.php 5KB
PinterestPlugin.php 5KB
DefaultValuesPropertiesTest.php 5KB
DatatypeTest.php 5KB
共 224 条
- 1
- 2
- 3
资源评论
Lee达森
- 粉丝: 1512
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- LitJson(0.19.0版本,适用于.NetStandard2.0)
- LitJson(0.19.0版本,适用于.NetStandard1.5)
- (源码)基于ROS的咖啡机器人控制系统.zip
- (源码)基于Qt和OpenCV的图像拼接系统.zip
- 《信号与系统》编程作业.zip
- (源码)基于C#的二级文件系统模拟.zip
- (源码)基于C++的巡飞弹三自由度弹道仿真系统.zip
- (源码)基于SpringBoot和Redis的短链接生成系统.zip
- (源码)基于Qt和GStreamer的条形码扫描系统.zip
- Apache Dubbo 是一个高性能的、基于 Java 的开源 RPC 框架 dubbo源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功