aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 6f074fb17bd2bcc03d52914f3f0dad6c3395b13b (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
1# jupyter-pspp
2
3A [GNU PSPP](https://www.gnu.org/software/pspp/) kernel for [Jupyter](https://jupyter.org/)
4
5## Repo contents
6
7The *jupyter_pspp* folder is the *jupyter_pspp* module which needs to be installed to Python.
8
9The *pspp* folder contains the [JSON kernel spec file](https://jupyter-client.readthedocs.io/en/latest/kernels.html#kernel-specs) for Jupyter.
10
11## Installation instructions
12
13Install the required dependency [Pexpect](https://pypi.org/project/pexpect/).
14
15Install the *jupyter_pspp* module folder to somewhere accessible by Python.
16
17Then run:
18
19```bash
20jupyter kernelspec install /path/to/pspp
21```
22
23Where */path/to/pspp* is the path to the *pspp* folder in this repository.
24
25## Usage
26
27You should now be able to create a new Jupyter notebook using the PSPP kernel.
28
29PSPP commands should behave as expected. Tables will be printed in HTML format. Headings in command output will not be printed unless associated with content.
30
31### Configuration
32
33You can configure *jupyter_pspp* by creating and running a cell with the contents:
34
35```
36%set [option] [value]
37```
38
39* **suppress_headings**: Controls whether headings in PSPP command output will be printed.
40  * *empty* (default): Don't print headings unless associated with content.
41  * *no*: Print all headings.
42  * *yes*: Do not print headings.
43
44Note: Setting options to invalid values results in undefined behaviour.
45
46You can silence the output of a cell by beginning a code block with the line `%silent`.
47
48You can hide certain tables from the output of a cell by beginning a code block with `%hide_table` followed on the same line by a comma-separated list of table captions. For example:
49
50```
51%hide_table Summary.,Ranks
52```
53
54### Running Python code
55
56You can also run Python code directly by beginning a code block with the line `%py`. `print()` will be automatically overridden to send output to Jupyter:
57
58```py
59%py
60print('Hello world!')
61```
62
63The output from the most recent PSPP execution will be accessible in `self.out`. A parsed version is accessible from `self.out_table`. For example, if we run:
64
65```
66CROSSTABS /TABLES=VarX BY VarY /STATISTICS=CORR.
67```
68
69We can then run:
70
71```py
72%py
73print(self.out_tables['CROSSTABS']['Symmetric measures.'].get_cell('Approx. T', 'Spearman Correlation'))
74```
75
76To obtain the value of the specified cell.
77
78## Notes
79
80There is no Windows support at present, as Windows does not support pseudo-TTYs, and file redirection puts PSPP into a synchronous processing mode. jupyter-pspp will work fine with PSPP under [Cygwin](https://www.cygwin.com/), but PSPP will need to be compiled from source.
Contact (issues, pull requests, etc.) at git@yingtongli.me. Generated by cgit.