summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md3
-rwxr-xr-xexamples/example.css8
-rwxr-xr-xexamples/extract.php8
-rwxr-xr-xexamples/filtering.php4
-rwxr-xr-xexamples/json.php2
-rwxr-xr-xexamples/stream.php6
-rwxr-xr-xexamples/table.php2
-rwxr-xr-xexamples/writing.php22
-rwxr-xr-xexamples/xml.php11
9 files changed, 35 insertions, 31 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b01742c..46894f4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,7 +2,7 @@
All Notable changes to `Csv` will be documented in this file
-## Next - 2015-xx-xx
+## 8.0.0 - 2015-12-11
### Added
@@ -20,6 +20,7 @@ All Notable changes to `Csv` will be documented in this file
- `Reader::fetchColumn` callable argument expects the selected column value as its first argument
- Default value on `setOutputBOM` is removed
- `AbstractCsv::getOutputBOM` always return a string
+- `AbstractCsv::getInputBOM` always return a string
### Removed
diff --git a/examples/example.css b/examples/example.css
index 9010a26..73180e2 100755
--- a/examples/example.css
+++ b/examples/example.css
@@ -13,10 +13,10 @@ pre {
line-height: 1.5;
text-align: left;
-webkit-tab-size: 4;
- -moz-tab-size: 4;
- -ms-tab-size: 4;
- -o-tab-size: 4;
- tab-size: 4;
+ -moz-tab-size: 4;
+ -ms-tab-size: 4;
+ -o-tab-size: 4;
+ tab-size: 4;
}
body {
margin:0 auto;
diff --git a/examples/extract.php b/examples/extract.php
index 53d3e19..61c768e 100755
--- a/examples/extract.php
+++ b/examples/extract.php
@@ -11,17 +11,17 @@ $inputCsv->setDelimiter(';');
$headers = $inputCsv->fetchOne(0);
//get at maximum 25 rows starting from the 801th row
-$res = $inputCsv->setOffset(800)->setLimit(25)->fetchAll();
+$res = $inputCsv->setOffset(800)->setLimit(25)->fetch();
?>
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
- <title>\League\Csv\Reader simple usage</title>
+ <title>League\Csv\Reader simple usage</title>
<link rel="stylesheet" href="example.css">
</head>
<body>
-<h1>\League\Csv\Reader simple usage</h1>
+<h1>League\Csv\Reader simple usage</h1>
<table class="table-csv-data">
<caption>Part of the CSV from the 801th row with at most 25 rows</caption>
<thead>
@@ -32,7 +32,7 @@ $res = $inputCsv->setOffset(800)->setLimit(25)->fetchAll();
<tbody>
<?php foreach ($res as $row) : ?>
<tr>
- <td><?=implode('</td>'.PHP_EOL.'<td>', $row), '</td>', PHP_EOL; ?>
+ <td><?=implode('</td>'.PHP_EOL.'<td>', $row), '</td>', PHP_EOL; ?>
</tr>
<?php
endforeach;
diff --git a/examples/filtering.php b/examples/filtering.php
index e6bea03..1f94fd7 100755
--- a/examples/filtering.php
+++ b/examples/filtering.php
@@ -28,7 +28,7 @@ $res = $inputCsv
return strcmp($row1[1], $row2[1]); //we order the result according to the number of firstname given
})
->setLimit(20) //we just want the first 20 results
- ->fetchAll();
+ ->fetch();
//get the headers
$headers = $inputCsv->fetchOne(0);
@@ -37,7 +37,7 @@ $headers = $inputCsv->fetchOne(0);
<html lang="fr">
<head>
<meta charset="iso-8859-15">
- <title>\League\Csv\Reader filtering method</title>
+ <title>League\Csv\Reader filtering method</title>
<link rel="stylesheet" href="example.css">
</head>
<body>
diff --git a/examples/json.php b/examples/json.php
index b86826e..60cddc8 100755
--- a/examples/json.php
+++ b/examples/json.php
@@ -7,6 +7,8 @@ require '../vendor/autoload.php';
$inputCsv = Reader::createFromPath('data/prenoms.csv');
$inputCsv->setDelimiter(';');
$inputCsv->setEncodingFrom('ISO-8859-15');
+//we limit the output to max. 10 rows
+$inputCsv->setLimit(10);
$res = json_encode($inputCsv, JSON_PRETTY_PRINT|JSON_HEX_QUOT|JSON_HEX_TAG|JSON_HEX_AMP|JSON_HEX_APOS);
if (JSON_ERROR_NONE != json_last_error()) {
die(json_last_error_msg());
diff --git a/examples/stream.php b/examples/stream.php
index 02b7ba6..2fe8d91 100755
--- a/examples/stream.php
+++ b/examples/stream.php
@@ -55,7 +55,7 @@ $reader->setOffset(6);
$reader->setLimit(3);
$res = $reader->fetchAssoc(['Prenom', 'Occurences', 'Sexe', 'Annee']);
-var_dump($res);
+var_dump(iterator_to_array($res, false));
?>
<p>Let's remove the <code><strong>string.toupper</strong></code> stream filter</p>
<pre><code>if ($reader->isActiveStreamFilter()) {
@@ -65,7 +65,7 @@ $reader->setOffset(6);
$reader->setLimit(3);
$res = $reader->fetchAssoc(['Prenom', 'Occurences', 'Sexe', 'Annee']);
-var_dump($res);</code></pre>
+var_dump(iterator_to_array($res, false));</code></pre>
<?php
if ($reader->isActiveStreamFilter()) {
@@ -75,7 +75,7 @@ $reader->setOffset(6);
$reader->setLimit(3);
$res = $reader->fetchAssoc(['Prenom', 'Occurences', 'Sexe', 'Annee']);
-var_dump($res);
+var_dump(iterator_to_array($res, false));
?>
<h3>Using the Writer class</h3>
diff --git a/examples/table.php b/examples/table.php
index 343569d..6e56781 100755
--- a/examples/table.php
+++ b/examples/table.php
@@ -7,7 +7,7 @@ require '../vendor/autoload.php';
$inputCsv = Reader::createFromPath('data/prenoms.csv');
$inputCsv->setDelimiter(';');
$inputCsv->setEncodingFrom("iso-8859-15");
-$inputCsv->setLimit(30);
+$inputCsv->setLimit(30); //we are limiting the convertion to the first 31 rows
?>
<!doctype html>
<html lang="fr">
diff --git a/examples/writing.php b/examples/writing.php
index 7447175..ebf4e9c 100755
--- a/examples/writing.php
+++ b/examples/writing.php
@@ -4,34 +4,34 @@ use League\Csv\Writer;
require '../vendor/autoload.php';
-$writer = Writer::createFromFileObject(new SplTempFileObject()); //the CSV file will be created into a temporary File
-$writer->setDelimiter("\t"); //the delimiter will be the tab character
-$writer->setNewline("\r\n"); //use windows line endings for compatibility with some csv libraries
-
-$headers = ["position" , "team", "played", "goals difference", "points"];
-$writer->insertOne($headers);
+$header = ["position" , "team", "played", "goals difference", "points"];
-$teams = [
+$contents = [
[1, "Chelsea", 26, 27, 57],
[2, "Arsenal", 26, 22, 56],
- [3, "Manchester City", 25, 41, 54],
+ [3, "Manchester City", 25, 41, 54,],
[4, "Liverpool", 26, 34, 53],
[5, "Tottenham", 26, 4, 50],
[6, "Everton", 25, 11, 45],
[7, "Manchester United", 26, 10, 42],
];
-$writer->insertAll($teams);
+$writer = Writer::createFromFileObject(new SplTempFileObject()); //the CSV file will be created using a temporary File
+$writer->setDelimiter("\t"); //the delimiter will be the tab character
+$writer->setNewline("\r\n"); //use windows line endings for compatibility with some csv libraries
+$writer->setOutputBOM(Writer::BOM_UTF8); //adding the BOM sequence on output
+$writer->insertOne($header);
+$writer->insertAll($contents);
?>
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
- <title>Using the \League\Csv\Writer object</title>
+ <title>Using the Writer class</title>
<link rel="stylesheet" href="example.css">
</head>
<body>
-<h1>Example 4: Using Writer object</h1>
+<h1>Example 4: Using the Writer class</h1>
<h3>The table representation of the csv</h3>
<?=$writer->toHTML('table-csv-data with-header');?>
<h3>The Raw CSV to be saved</h3>
diff --git a/examples/xml.php b/examples/xml.php
index 3104680..86b34c9 100755
--- a/examples/xml.php
+++ b/examples/xml.php
@@ -4,16 +4,17 @@ use League\Csv\Reader;
require '../vendor/autoload.php';
+ //we order the result according to the number of firstname given
+$func = function ($row1, $row2) {
+ return strcmp($row2[1], $row1[1]);
+};
+
$csv = Reader::createFromPath('data/prenoms.csv');
$csv->setEncodingFrom('ISO-8859-15');
-$csv->setFlags(SplFileObject::READ_AHEAD|SplFileObject::SKIP_EMPTY);
$csv->setDelimiter(';');
-//since version 7.0 only 10 rows will be converted using the query options
$csv->setOffset(1);
$csv->setLimit(10);
-$csv->addSortBy(function ($row1, $row2) {
- return strcmp($row2[1], $row1[1]); //we order the result according to the number of firstname given
-});
+$csv->addSortBy($func);
$doc = $csv->toXML('csv', 'ligne', 'cellule');
$xml = $doc->saveXML();
header('Content-Type: application/xml; charset="utf-8"');