Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mhndev/csv
library for working with csv
https://github.com/mhndev/csv
csv csv-database csv-parser csv-reader
Last synced: 2 months ago
JSON representation
library for working with csv
- Host: GitHub
- URL: https://github.com/mhndev/csv
- Owner: mhndev
- License: other
- Created: 2016-05-17T11:21:49.000Z (over 8 years ago)
- Default Branch: develop
- Last Pushed: 2017-02-20T07:40:33.000Z (almost 8 years ago)
- Last Synced: 2024-02-05T13:41:01.242Z (11 months ago)
- Topics: csv, csv-database, csv-parser, csv-reader
- Language: PHP
- Size: 20.5 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/mhndev/csv.svg?branch=1.3.1)](https://travis-ci.org/mhndev/csv)
## CSV
powerful and fully tested php library to work with csv files
### features :
#### convert an array to a csv file
#### convert a csv file to an array
#### convert a csv file to an array using php generators
#### delete a line from csv file by line number
#### delete multiple line from csv file by specific column value
#### update a line from a csv file by line number
#### update multiple line from a csv file by specific column value
#### find one line from a csv file by specific column value
#### find many line from a csv file by specific column value## Sample Usage
```php
use mhndev\csv\Csv;
$csv = new Csv();
$sampleArray = [[1,2,3,4,5],[6,7,8,9,10]];
$filename ="/path/to/test.csv";
$csv->arrayToCsv($sampleArray, $filename);
$resultArrayIterator = $csv->csvToArrayUsingGenerator($filename);$csv = new Csv();
$sampleArray = [[1,2,3,4,5],[6,7,8,9,10],[11,12,13,14,15]];
$filename ="/path/to/test.csv";
$csv->arrayToCsv($sampleArray, $filename);
$csv->deleteOneLineById($filename, 1);$csv = new Csv();
$sampleArray = [[1,2,3,4,5],[6,7,8,9,10],[6,'hamid',8,9,'majid']];
$filename ="/path/to/test.csv";
$csv->arrayToCsv($sampleArray, $filename);
$csv->updateLineBy($filename, [2=>8] , [11,12,13,14,15]);```