mirror of
https://github.com/parsecsv/parsecsv-for-php.git
synced 2026-02-19 08:36:39 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d6236cae0 | ||
|
|
f2b0aecd12 | ||
|
|
5d4643b201 | ||
| d5606f8b2a | |||
| 8cebcbd9bb | |||
| 518f5081fb | |||
|
|
a28fc6ab0a |
@@ -14,5 +14,8 @@ insert_final_newline = true
|
||||
[composer.json]
|
||||
indent_size = 4
|
||||
|
||||
[.travis.yml]
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
|
||||
[*.yml,*.yaml]
|
||||
indent_size = 2
|
||||
|
||||
38
.github/workflows/ci.yml
vendored
Normal file
38
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
name: CI
|
||||
on:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php_version:
|
||||
- "7.4"
|
||||
- "7.3"
|
||||
- "7.2"
|
||||
- "7.1"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php_version }}
|
||||
env:
|
||||
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Get composer cache directory
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: ${{ runner.os }}-composer-
|
||||
- name: Install dependencies
|
||||
run: composer update
|
||||
- name: Validate dependencies
|
||||
run: composer validate
|
||||
- name: Run tests
|
||||
run: vendor/bin/phpunit --configuration tests/phpunit.xml
|
||||
24
.travis.yml
24
.travis.yml
@@ -1,24 +0,0 @@
|
||||
dist: trusty
|
||||
language: php
|
||||
dist: trusty
|
||||
|
||||
php:
|
||||
- '7.4'
|
||||
- '7.3'
|
||||
- '7.2'
|
||||
- '7.1'
|
||||
|
||||
before_install:
|
||||
- composer update
|
||||
|
||||
script:
|
||||
- composer validate
|
||||
- vendor/bin/phpunit --version
|
||||
- vendor/bin/phpunit --configuration tests/phpunit.xml
|
||||
|
||||
notifications:
|
||||
email:
|
||||
recipients:
|
||||
- will.knauss@gmail.com
|
||||
on_success: never
|
||||
on_failure: always
|
||||
@@ -1,3 +1,16 @@
|
||||
ParseCSV 1.3.2
|
||||
-----------------------------------
|
||||
Date: 07-Nov-2021
|
||||
|
||||
Bugfix:
|
||||
- Allow _guess_delimiter to work with a single
|
||||
row of data. As a consequence, `$csv->auto()`
|
||||
now works for files with just one row of data.
|
||||
See issue #206.
|
||||
|
||||
-----------------------------------
|
||||
|
||||
|
||||
ParseCSV 1.3.1
|
||||
-----------------------------------
|
||||
Date: 20-Jun-2021
|
||||
|
||||
18
Makefile
18
Makefile
@@ -11,5 +11,21 @@ phpunit-dep:
|
||||
exit 1 \
|
||||
)
|
||||
|
||||
# Requires:
|
||||
# - Docker: https://docker.com
|
||||
# - act: https://github.com/nektos/act
|
||||
local-ci:
|
||||
ifeq (, $(shell which act))
|
||||
define ACT_ERROR
|
||||
Consider running the following to install 'act':
|
||||
|
||||
curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
|
||||
|
||||
The dependency 'act' was not found
|
||||
endef
|
||||
$(error ${ACT_ERROR})
|
||||
endif
|
||||
act -P ubuntu-latest=shivammathur/node:latest -W .github/workflows/ci.yml
|
||||
|
||||
.SILENT:
|
||||
.PHONY: test phpunit-dep
|
||||
.PHONY: test phpunit-dep local-ci
|
||||
|
||||
@@ -165,8 +165,12 @@ composer install
|
||||
composer run test
|
||||
````
|
||||
|
||||
When pushing code to GitHub, tests will be executed using Travis CI. The relevant configuration is in the
|
||||
file `.travis.yml`.
|
||||
When pushing code to GitHub, tests will be executed using GitHub Actions. The relevant configuration is in the
|
||||
file `.github/workflows/ci.yml`. To run the `test` action locally, you can execute the following command:
|
||||
|
||||
````bash
|
||||
make local-ci
|
||||
````
|
||||
|
||||
## Security
|
||||
|
||||
|
||||
@@ -1248,7 +1248,7 @@ class Csv {
|
||||
$first = null;
|
||||
$equal = null;
|
||||
$almost = false;
|
||||
foreach ($array as $key => $value) {
|
||||
foreach ($array as $value) {
|
||||
if ($first == null) {
|
||||
$first = $value;
|
||||
} elseif ($value == $first && $equal !== false) {
|
||||
@@ -1261,7 +1261,7 @@ class Csv {
|
||||
}
|
||||
}
|
||||
|
||||
if ($equal) {
|
||||
if ($equal || $depth === 1) {
|
||||
$match = $almost ? 2 : 1;
|
||||
$pref = strpos($preferred, $char);
|
||||
$pref = ($pref !== false) ? str_pad($pref, 3, '0', STR_PAD_LEFT) : '999';
|
||||
@@ -1405,7 +1405,7 @@ class Csv {
|
||||
$is_newline = ($ch == "\n" && $pch != "\r") || $ch == "\r";
|
||||
if ($ch == $enclosure) {
|
||||
if (!$enclosed || $nch != $enclosure) {
|
||||
$enclosed = $enclosed ? false : true;
|
||||
$enclosed = !$enclosed;
|
||||
} elseif ($enclosed) {
|
||||
$i++;
|
||||
}
|
||||
|
||||
1
tests/example_files/single_row.csv
Normal file
1
tests/example_files/single_row.csv
Normal file
@@ -0,0 +1 @@
|
||||
C1,C2,C3
|
||||
|
@@ -121,6 +121,15 @@ class ParseTest extends TestCase {
|
||||
self::assertEquals($expected, $this->csv->data);
|
||||
}
|
||||
|
||||
public function testSingleRow() {
|
||||
$this->csv->auto(__DIR__ . '/../example_files/single_row.csv');
|
||||
self::assertEquals([], $this->csv->data, 'Single row is detected as header');
|
||||
$this->csv->heading = false;
|
||||
$this->csv->auto(__DIR__ . '/../example_files/single_row.csv');
|
||||
$expected = [['C1', 'C2', 'C3']];
|
||||
self::assertEquals($expected, $this->csv->data);
|
||||
}
|
||||
|
||||
public function testMatomoData() {
|
||||
// Matomo (Piwik) export cannot be read with
|
||||
$this->csv->use_mb_convert_encoding = true;
|
||||
|
||||
Reference in New Issue
Block a user