Download the PHP package dutchcodingcompany/csv-collection without Composer
On this page you can find all versions of the php package dutchcodingcompany/csv-collection. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dutchcodingcompany/csv-collection
More information about dutchcodingcompany/csv-collection
Files in dutchcodingcompany/csv-collection
Package csv-collection
Short Description Read and write large csv files using Laravel's Illuminate Collections
License MIT
Homepage https://dutchcodingcompany.com
Informations about the package csv-collection
CSV Collection
This package provides a simple but powerful way to read and write large CSV files using the power of Laravel's lazy collections.
Installation
You can install the package via composer:
Usage
You may create a collection using the new
keyword or the make
method.
This gives you access to all Collection and Lazy Collection methods.
Open
To open a file and load it's content into a new collection you may use the open
method on the collection.
Save
To save the collection items to a file you may use the save
method on the collection.
Model exports
When exporting models a memory efficient method is to lazily iterate through the models and yield
it's content.
Options
The following options are available to suit your needs:
header
, default:true
delimiter
, default:,
enclosure
, default:"
escape
, default:\\
These options could be passed to the open
and save
methods, be set using the options
method, or be set as the
global default using the static defaults
method.
The delimiter can be detected for a file by using the detectDelimiter
method like this:
Header
When using a header, lines will contain an associated array. Otherwise, lines will contain an indexed array.
Note: When saving a collection to a file the keys of the first element in the collection will be used as the header.
Testing
Credits
License
The MIT License (MIT). Please see License File for more information.