forked from tiamo/spss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
read.php
65 lines (47 loc) · 1.24 KB
/
read.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
require __DIR__ . '/../vendor/autoload.php';
$files = array(
// __DIR__ . '/test2.sav',
__DIR__ . '/data.sav',
);
function __header($str, $char = '#')
{
$line = str_repeat($char, 100);
$res = '';
$res .= $line . PHP_EOL;
$res .= "#\t\t" . $str . PHP_EOL;
$res .= $line . PHP_EOL;
return $res;
}
function __title($title, $char = '.')
{
return PHP_EOL .
str_repeat($char, 10) . ' ' .
mb_strtoupper($title) . ' ' .
str_repeat($char, 70) .
PHP_EOL;
}
function __content($data)
{
$data = json_encode($data);
// $data = json_decode($data, true);
return print_r($data, true);
}
foreach ($files as $file) {
$reader = \SPSS\Sav\Reader::fromFile($file)->read();
echo PHP_EOL;
echo __header(sprintf('OPEN FILE %s', $file));
echo __title('Header');
echo __content($reader->header);
echo __title('Documents');
echo __content($reader->documents);
echo __title('Variables');
echo __content($reader->variables);
echo __title('Values-labels');
echo __content($reader->valueLabels);
echo __title('Additional-info');
echo __content($reader->info);
echo __title('Data');
echo __content($reader->data);
echo PHP_EOL;
}