flobee / spss
SPSS is a php-based implementation of IBM SPSS Statistics Standard. (Read/write SPSS, PSPP .sav files)
Fund package maintenance!
www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9UFPH5MGUD7LS&source=url
Installs: 17 919
Dependents: 1
Suggesters: 0
Security: 0
Stars: 11
Watchers: 4
Forks: 6
Open Issues: 1
Requires
- php: >=5.6
- ext-bcmath: *
- ext-mbstring: *
Requires (Dev)
- composer/composer: ^2.1.
- friendsofphp/php-cs-fixer: ^2.16
- phing/phing: *
- phpunit/phpunit: ^5.7 || ^6.4 || ^7.0 || ^9
- squizlabs/php_codesniffer: *
README
project currently not maintained. Check github.com/tiamo/spss
A PHP library for reading and writing SPSS / PSPP .sav data files.
VERSION 4.* (see upgrade section for details)
Fork of tiamo/spss. Mostly same code base. Introdusing a more complete test enviroment which now exists over there. So, one day i switch back to it.
Table of contents
Requirements
PHP 8.0 and up.
- php-cli
- php-mdstring
- php-bcmath
Installation
The preferred way to install this extension is through composer
Either run
composer require flobee/spss
to the require section of your composer.json
file see here
or download from here.
Usage
In folder examples/ you will find some more examples.
Reader example:
$reader = \SPSS\Sav\Reader::fromFile('path/to/file.sav')->read();
or
$reader = \SPSS\Sav\Reader::fromString(file_get_contents('path/to/file.sav'))->read();
Writer example:
$writer = new \SPSS\Sav\Writer([
'header' => [
'prodName' => '@(#) SPSS DATA FILE test',
'layoutCode' => 2,
'compression' => 1,
'weightIndex' => 0,
'bias' => 100,
'creationDate' => '13 Feb 89',
'creationTime' => '23:58:59',
],
'variables' => [
[
'name' => 'VAR1',
'width' => 0,
'decimals' => 0
'format' => 5,
'columns' => 50,
'align' => 1,
'measure' => 1,
'data' => [
1, 2, 3
],
],
...
]
]);
...
Tests / Developers
Install using shell
git clone https://github.com/flobee/spss.git
cd spss/
git submodule init # once
git submodule update --recursive # upgrading (after a `git pull`)
Initialy or for upgrades to get development dependencies:
composer install
For more dev-tools you may install phpstan/phpstan composer require -dev phpstan/phpstan
which shows a lot of stucture problems of the application and it should getting more
attention (beginning with level=1).
Update existing code
git pull
git submodule update
composer install
Running tests
VERSION 4:
Improved additions for CI systems (e.g: jenkins) where `phing` is the
prefered build tool. `composer` the prefered package manager.
# shows you the options
./phing -l
# executes the tests
./phing test
# executes the tests and create the code coverage
./phing coverage
# run all tasks (CS checks, coverage, tests, sca...)
./phing all
...
cd tests
sh ./runTests.sh
# have a look at ../docs/CodeCoverage (use a browser after execution)
sh ./runTestsCoverageCreate.sh
# playground:
php readerDemo.php | less
# or to update tmp file to check for changes:
php readerDemo.php > data/pspp.sav.printr.txt
Upgrade to version 3.*
Update your composer.json
{
...
"require": {
"flobee/spss": "3.*",
},
...
}
Next:
composer update flobee/spss
Dependency Errors?
If you get dependency errors, you may upgrade other spss dependencies too. If so try the following:
composer update flobee/spss --with-dependencies
Changelog
Please have a look in docs/CHANGELOG.md
License
Please have a look in License text