SPSS php implementation

Maintainers

Details

github.com/sakalauskas/spss

Source

Installs: 9 162

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 37

2.2.1 2017-07-28 13:29 UTC

This package is not auto-updated.

Last update: 2025-04-17 08:33:29 UTC


README

A PHP library for reading and writing SPSS data files.

Requirements

  • PHP 5.3.0 and up.

Installation

The preferred way to install this extension is through composer.

Either run

composer require sakalauskas/spss 

or add

"sakalauskas/spss": "^2.0"

to the require section of your composer.json file.

Usage

Reader example:

$reader = \SPSS\Reader::fromFile('path/to/file.sav');

or

$reader = \SPSS\Reader::fromString(file_get_contents('path/to/file.sav'));

Writer example:

$writer = new \SPSS\Writer([
    'header' => [
            'prodName'     => '@(#) SPSS DATA FILE test',
            'layoutCode'   => 2,
            'compression'  => 1,
            'weightIndex'  => 0,
            'bias'         => 100,
            'creationDate' => '13 Feb 89',
            'creationTime' => '13:13:13',
    ],
    'variables' => [
        [
                'name'     => 'VAR1',
                'width'    => 0,
                'decimals' => 0,
                'format'   => 5,
                'columns'  => 50,
                'align'    => 1,
                'measure'  => 1,
                'data'     => [
                    1, 2, 3
                ],
        ],
        ...
    ]
]);

License

Licensed under the MIT license.