Simple PHP Class to Validate CSV Files
via Composer:
composer require svenkuegler/php-csv-validator
Simple example to validate a file against a Schema.
require 'vendor/autoload.php';
$validator = new PhpCsvValidator();
$validator->loadSchemeFromFile("tests/files/example-scheme2.json");
if($validator->isValidFile("tests/files/example.csv")) {
echo "File is Valid";
} else {
echo "File is Invalid!";
}
...
...
$ phpunit
Feel free to send pull requests or create issues if you come across problems or have great ideas. Any input is appreciated!
This code is published under the The MIT License. This means you can do almost anything with it, as long as the copyright notice and the accompanying license file is left intact.