@@ -11,7 +11,7 @@ such as a list of user records or log entries. CSV is not exactly a new format
11
11
and has been used in a large number of systems for decades. In particular, CSV
12
12
is often used for historical reasons and despite its shortcomings, it is still a
13
13
very common export format for a large number of tools to interface with
14
- spreadsheet processors (such as Exel , Calc etc.). This library provides a simple
14
+ spreadsheet processors (such as Excel , Calc etc.). This library provides a simple
15
15
streaming API to process very large CSV files with thousands or even millions of
16
16
rows efficiently without having to load the whole file into memory at once.
17
17
@@ -40,7 +40,7 @@ rows efficiently without having to load the whole file into memory at once.
40
40
41
41
## Support us
42
42
43
- We invest a lot of time developing, maintaining and updating our awesome
43
+ We invest a lot of time developing, maintaining, and updating our awesome
44
44
open-source projects. You can help us sustain this high-quality of our work by
45
45
[ becoming a sponsor on GitHub] ( https://github.com/sponsors/clue ) . Sponsors get
46
46
numerous benefits in return, see our [ sponsoring page] ( https://github.com/sponsors/clue )
@@ -96,9 +96,9 @@ World!"
96
96
started using some CSV-variant long before this standard was defined.
97
97
98
98
Some applications refer to CSV as Character-Separated Values, simply because
99
- using another delimiter (such as semicolon or tab) is a rather common approach
99
+ using another delimiter (such as a semicolon or tab) is a rather common approach
100
100
to avoid the need to enclose common values in quotes. This is particularly
101
- common for systems in Europe (and elsewhere) that use a comma as decimal separator.
101
+ common for systems in Europe (and elsewhere) that use a comma as a decimal separator.
102
102
103
103
```
104
104
name;comment
@@ -115,7 +115,7 @@ consistently.
115
115
116
116
Despite its shortcomings, CSV is widely used and this is unlikely to change any
117
117
time soon. In particular, CSV is a very common export format for a lot of tools
118
- to interface with spreadsheet processors (such as Exel , Calc etc.). This means
118
+ to interface with spreadsheet processors (such as Excel , Calc etc.). This means
119
119
that CSV is often used for historical reasons and using CSV to store structured
120
120
application data is usually not a good idea nowadays – but exporting to CSV for
121
121
known applications continues to be a very reasonable approach.
@@ -155,11 +155,11 @@ test,1,24
155
155
"hello world",2,48
156
156
```
157
157
``` php
158
- $stdin = new ReadableResourceStream(STDIN);
158
+ $stdin = new React\Stream\ ReadableResourceStream(STDIN);
159
159
160
- $csv = new Decoder($stdin);
160
+ $csv = new Clue\React\Csv\ Decoder($stdin);
161
161
162
- $csv->on('data', function ($data) {
162
+ $csv->on('data', function (array $data) {
163
163
// $data is a parsed element from the CSV stream
164
164
// line 1: $data = array('test', '1', '24');
165
165
// line 2: $data = array('hello world', '2', '48');
@@ -179,9 +179,9 @@ use a quote enclosure character (`"`) and a backslash escape character (`\`).
179
179
This behavior can be controlled through the optional constructor parameters:
180
180
181
181
``` php
182
- $csv = new Decoder($stdin, ';');
182
+ $csv = new Clue\React\Csv\ Decoder($stdin, ';');
183
183
184
- $csv->on('data', function ($data) {
184
+ $csv->on('data', function (array $data) {
185
185
// CSV fields will now be delimited by semicolon
186
186
});
187
187
```
@@ -193,7 +193,7 @@ unreasonably long lines. It accepts an additional argument if you want to change
193
193
this from the default of 64 KiB:
194
194
195
195
``` php
196
- $csv = new Decoder($stdin, ',', '"', '\\', 64 * 1024);
196
+ $csv = new Clue\React\Csv\ Decoder($stdin, ',', '"', '\\', 64 * 1024);
197
197
```
198
198
199
199
If the underlying stream emits an ` error ` event or the plain stream contains
@@ -261,11 +261,11 @@ test,1
261
261
"hello world",2
262
262
```
263
263
``` php
264
- $stdin = new ReadableResourceStream(STDIN);
264
+ $stdin = new React\Stream\ ReadableResourceStream(STDIN);
265
265
266
- $csv = new AssocDecoder($stdin);
266
+ $csv = new Clue\React\Csv\ AssocDecoder($stdin);
267
267
268
- $csv->on('data', function ($data) {
268
+ $csv->on('data', function (array $data) {
269
269
// $data is a parsed element from the CSV stream
270
270
// line 1: $data = array('name' => 'test', 'id' => '1');
271
271
// line 2: $data = array('name' => 'hello world', 'id' => '2');
@@ -312,9 +312,9 @@ and accepts its data through the same interface, but handles any data as complet
312
312
CSV elements instead of just chunks of strings:
313
313
314
314
``` php
315
- $stdout = new WritableResourceStream(STDOUT);
315
+ $stdout = new React\Stream\ WritableResourceStream(STDOUT);
316
316
317
- $csv = new Encoder($stdout);
317
+ $csv = new Clue\React\Csv\ Encoder($stdout);
318
318
319
319
$csv->write(array('test', true, 24));
320
320
$csv->write(array('hello world', 2, 48));
@@ -332,7 +332,7 @@ a Unix-style EOL (`\n` or `LF`).
332
332
This behavior can be controlled through the optional constructor parameters:
333
333
334
334
``` php
335
- $csv = new Encoder($stdout, ';');
335
+ $csv = new Clue\React\Csv\ Encoder($stdout, ';');
336
336
337
337
$csv->write(array('hello', 'world'));
338
338
```
@@ -379,7 +379,7 @@ For more details, see ReactPHP's
379
379
380
380
## Install
381
381
382
- The recommended way to install this library is [ through Composer] ( https://getcomposer.org ) .
382
+ The recommended way to install this library is [ through Composer] ( https://getcomposer.org/ ) .
383
383
[ New to Composer?] ( https://getcomposer.org/doc/00-intro.md )
384
384
385
385
This project follows [ SemVer] ( https://semver.org/ ) .
@@ -394,12 +394,12 @@ See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.
394
394
This project aims to run on any platform and thus does not require any PHP
395
395
extensions and supports running on legacy PHP 5.3 through current PHP 8+ and
396
396
HHVM.
397
- It's * highly recommended to use the latest supported PHP version PHP 7+ * for this project.
397
+ It's * highly recommended to use the latest supported PHP version* for this project.
398
398
399
399
## Tests
400
400
401
401
To run the test suite, you first need to clone this repo and then install all
402
- dependencies [ through Composer] ( https://getcomposer.org ) :
402
+ dependencies [ through Composer] ( https://getcomposer.org/ ) :
403
403
404
404
``` bash
405
405
$ composer install
@@ -408,7 +408,7 @@ $ composer install
408
408
To run the test suite, go to the project root and run:
409
409
410
410
``` bash
411
- $ php vendor/bin/phpunit
411
+ $ vendor/bin/phpunit
412
412
```
413
413
414
414
## License
0 commit comments