Skip to content

Commit

Permalink
docs: add example
Browse files Browse the repository at this point in the history
  • Loading branch information
odinuv committed May 18, 2018
1 parent d46e83e commit d80c540
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ foreach($csvFile as $row) {
Skip the first line:

```php
$csvFile = new \Keboola\Csv\CsvFile($fileName, CsvFile::DEFAULT_DELIMITER, CsvFile::DEFAULT_ENCLOSURE, CsvFile::DEFAULT_ESCAPED_BY, 1)
$csvFile = new \Keboola\Csv\CsvFile(
$fileName,
CsvFile::DEFAULT_DELIMITER,
CsvFile::DEFAULT_ENCLOSURE,
CsvFile::DEFAULT_ESCAPED_BY,
1
)
foreach($csvFile as $row) {
var_dump($row);
}
Expand Down Expand Up @@ -71,6 +77,29 @@ foreach ($rows as $row) {
fclose($file);
```

### Write CSV With Windows new-lines

```php
$csvFile = new Keboola\Csv\CsvWriter(
'test-output.csv',
CsvWriter::DEFAULT_DELIMITER,
CsvWriter::DEFAULT_ENCLOSURE,
"\r\n"
)
$rows = [
[
'col1', 'col2',
],
[
'first column', 'second column',
],
];

foreach ($rows as $row) {
$csvFile->writeRow($row);
}
```

## Installation

The library is available as [composer package](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx).
Expand Down

0 comments on commit d80c540

Please sign in to comment.