betteroff 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- betteroff-0.1.0/.gitignore +227 -0
- betteroff-0.1.0/CHANGELOG.md +16 -0
- betteroff-0.1.0/LICENSE +21 -0
- betteroff-0.1.0/PKG-INFO +247 -0
- betteroff-0.1.0/README.md +212 -0
- betteroff-0.1.0/docs/charts.md +57 -0
- betteroff-0.1.0/docs/cli.md +125 -0
- betteroff-0.1.0/docs/data.md +131 -0
- betteroff-0.1.0/docs/python.md +110 -0
- betteroff-0.1.0/docs/recipes.md +93 -0
- betteroff-0.1.0/docs/releasing.md +77 -0
- betteroff-0.1.0/pyproject.toml +103 -0
- betteroff-0.1.0/src/betteroff/__init__.py +54 -0
- betteroff-0.1.0/src/betteroff/__main__.py +3 -0
- betteroff-0.1.0/src/betteroff/_version.py +24 -0
- betteroff-0.1.0/src/betteroff/api.py +280 -0
- betteroff-0.1.0/src/betteroff/cache.py +142 -0
- betteroff-0.1.0/src/betteroff/catalog.py +159 -0
- betteroff-0.1.0/src/betteroff/charts.py +537 -0
- betteroff-0.1.0/src/betteroff/cli.py +553 -0
- betteroff-0.1.0/src/betteroff/data/catalog.toml +270 -0
- betteroff-0.1.0/src/betteroff/data/recessions.csv +14 -0
- betteroff-0.1.0/src/betteroff/errors.py +39 -0
- betteroff-0.1.0/src/betteroff/export.py +86 -0
- betteroff-0.1.0/src/betteroff/fetch.py +136 -0
- betteroff-0.1.0/src/betteroff/models.py +129 -0
- betteroff-0.1.0/src/betteroff/parsers/__init__.py +1 -0
- betteroff-0.1.0/src/betteroff/parsers/historical.py +187 -0
- betteroff-0.1.0/src/betteroff/py.typed +0 -0
- betteroff-0.1.0/src/betteroff/recipes.py +212 -0
- betteroff-0.1.0/src/betteroff/validate.py +93 -0
- betteroff-0.1.0/tests/__init__.py +0 -0
- betteroff-0.1.0/tests/conftest.py +161 -0
- betteroff-0.1.0/tests/test_api.py +139 -0
- betteroff-0.1.0/tests/test_catalog.py +51 -0
- betteroff-0.1.0/tests/test_charts.py +228 -0
- betteroff-0.1.0/tests/test_cli.py +219 -0
- betteroff-0.1.0/tests/test_export.py +137 -0
- betteroff-0.1.0/tests/test_fetch.py +101 -0
- betteroff-0.1.0/tests/test_live.py +54 -0
- betteroff-0.1.0/tests/test_parser.py +108 -0
- betteroff-0.1.0/tests/test_recipes.py +83 -0
- betteroff-0.1.0/tests/test_validate.py +42 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
# Betteroff
|
|
2
|
+
src/betteroff/_version.py
|
|
3
|
+
# Michigan's usage agreement bars redistribution; never commit source downloads.
|
|
4
|
+
*.xls
|
|
5
|
+
output/
|
|
6
|
+
.DS_Store
|
|
7
|
+
|
|
8
|
+
# Byte-compiled / optimized / DLL files
|
|
9
|
+
__pycache__/
|
|
10
|
+
*.py[codz]
|
|
11
|
+
*$py.class
|
|
12
|
+
|
|
13
|
+
# C extensions
|
|
14
|
+
*.so
|
|
15
|
+
|
|
16
|
+
# Distribution / packaging
|
|
17
|
+
.Python
|
|
18
|
+
build/
|
|
19
|
+
develop-eggs/
|
|
20
|
+
dist/
|
|
21
|
+
downloads/
|
|
22
|
+
eggs/
|
|
23
|
+
.eggs/
|
|
24
|
+
lib/
|
|
25
|
+
lib64/
|
|
26
|
+
parts/
|
|
27
|
+
sdist/
|
|
28
|
+
var/
|
|
29
|
+
wheels/
|
|
30
|
+
share/python-wheels/
|
|
31
|
+
*.egg-info/
|
|
32
|
+
.installed.cfg
|
|
33
|
+
*.egg
|
|
34
|
+
MANIFEST
|
|
35
|
+
|
|
36
|
+
# PyInstaller
|
|
37
|
+
# Usually these files are written by a python script from a template
|
|
38
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
39
|
+
*.manifest
|
|
40
|
+
*.spec
|
|
41
|
+
|
|
42
|
+
# Installer logs
|
|
43
|
+
pip-log.txt
|
|
44
|
+
pip-delete-this-directory.txt
|
|
45
|
+
|
|
46
|
+
# Unit test / coverage reports
|
|
47
|
+
htmlcov/
|
|
48
|
+
.tox/
|
|
49
|
+
.nox/
|
|
50
|
+
.coverage
|
|
51
|
+
.coverage.*
|
|
52
|
+
.cache
|
|
53
|
+
nosetests.xml
|
|
54
|
+
coverage.xml
|
|
55
|
+
*.cover
|
|
56
|
+
*.py.cover
|
|
57
|
+
*.lcov
|
|
58
|
+
.hypothesis/
|
|
59
|
+
.pytest_cache/
|
|
60
|
+
cover/
|
|
61
|
+
|
|
62
|
+
# Translations
|
|
63
|
+
*.mo
|
|
64
|
+
*.pot
|
|
65
|
+
|
|
66
|
+
# Django stuff:
|
|
67
|
+
*.log
|
|
68
|
+
local_settings.py
|
|
69
|
+
db.sqlite3
|
|
70
|
+
db.sqlite3-journal
|
|
71
|
+
|
|
72
|
+
# Flask stuff:
|
|
73
|
+
instance/
|
|
74
|
+
.webassets-cache
|
|
75
|
+
|
|
76
|
+
# Scrapy stuff:
|
|
77
|
+
.scrapy
|
|
78
|
+
|
|
79
|
+
# Sphinx documentation
|
|
80
|
+
docs/_build/
|
|
81
|
+
|
|
82
|
+
# PyBuilder
|
|
83
|
+
.pybuilder/
|
|
84
|
+
target/
|
|
85
|
+
|
|
86
|
+
# Jupyter Notebook
|
|
87
|
+
.ipynb_checkpoints
|
|
88
|
+
|
|
89
|
+
# IPython
|
|
90
|
+
profile_default/
|
|
91
|
+
ipython_config.py
|
|
92
|
+
|
|
93
|
+
# pyenv
|
|
94
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
95
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
96
|
+
# .python-version
|
|
97
|
+
|
|
98
|
+
# pipenv
|
|
99
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
100
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
101
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
102
|
+
# install all needed dependencies.
|
|
103
|
+
# Pipfile.lock
|
|
104
|
+
|
|
105
|
+
# uv
|
|
106
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
107
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
108
|
+
# commonly ignored for libraries.
|
|
109
|
+
# uv.lock
|
|
110
|
+
|
|
111
|
+
# poetry
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
113
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
114
|
+
# commonly ignored for libraries.
|
|
115
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
116
|
+
# poetry.lock
|
|
117
|
+
# poetry.toml
|
|
118
|
+
|
|
119
|
+
# pdm
|
|
120
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
121
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
122
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
123
|
+
# pdm.lock
|
|
124
|
+
# pdm.toml
|
|
125
|
+
.pdm-python
|
|
126
|
+
.pdm-build/
|
|
127
|
+
|
|
128
|
+
# pixi
|
|
129
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
130
|
+
# pixi.lock
|
|
131
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
132
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
133
|
+
.pixi/*
|
|
134
|
+
!.pixi/config.toml
|
|
135
|
+
|
|
136
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
137
|
+
__pypackages__/
|
|
138
|
+
|
|
139
|
+
# Celery stuff
|
|
140
|
+
celerybeat-schedule*
|
|
141
|
+
celerybeat.pid
|
|
142
|
+
|
|
143
|
+
# Redis
|
|
144
|
+
*.rdb
|
|
145
|
+
*.aof
|
|
146
|
+
*.pid
|
|
147
|
+
|
|
148
|
+
# RabbitMQ
|
|
149
|
+
mnesia/
|
|
150
|
+
rabbitmq/
|
|
151
|
+
rabbitmq-data/
|
|
152
|
+
|
|
153
|
+
# ActiveMQ
|
|
154
|
+
activemq-data/
|
|
155
|
+
|
|
156
|
+
# SageMath parsed files
|
|
157
|
+
*.sage.py
|
|
158
|
+
|
|
159
|
+
# Environments
|
|
160
|
+
.env
|
|
161
|
+
.envrc
|
|
162
|
+
.venv
|
|
163
|
+
env/
|
|
164
|
+
venv/
|
|
165
|
+
ENV/
|
|
166
|
+
env.bak/
|
|
167
|
+
venv.bak/
|
|
168
|
+
|
|
169
|
+
# Spyder project settings
|
|
170
|
+
.spyderproject
|
|
171
|
+
.spyproject
|
|
172
|
+
|
|
173
|
+
# Rope project settings
|
|
174
|
+
.ropeproject
|
|
175
|
+
|
|
176
|
+
# mkdocs/Zensical documentation
|
|
177
|
+
/site
|
|
178
|
+
|
|
179
|
+
# mypy
|
|
180
|
+
.mypy_cache/
|
|
181
|
+
.dmypy.json
|
|
182
|
+
dmypy.json
|
|
183
|
+
|
|
184
|
+
# Pyre type checker
|
|
185
|
+
.pyre/
|
|
186
|
+
|
|
187
|
+
# pytype static type analyzer
|
|
188
|
+
.pytype/
|
|
189
|
+
|
|
190
|
+
# Cython debug symbols
|
|
191
|
+
cython_debug/
|
|
192
|
+
|
|
193
|
+
# PyCharm
|
|
194
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
195
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
196
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
197
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
198
|
+
# .idea/
|
|
199
|
+
|
|
200
|
+
# Abstra
|
|
201
|
+
# Abstra is an AI-powered process automation framework.
|
|
202
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
203
|
+
# Learn more at https://abstra.io/docs
|
|
204
|
+
.abstra/
|
|
205
|
+
|
|
206
|
+
# Visual Studio Code
|
|
207
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore that
|
|
208
|
+
# can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
209
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer, you
|
|
210
|
+
# could uncomment the following to ignore the entire vscode folder
|
|
211
|
+
# .vscode/
|
|
212
|
+
# Temporary file for partial code execution
|
|
213
|
+
tempCodeRunnerFile.py
|
|
214
|
+
|
|
215
|
+
# Ruff stuff:
|
|
216
|
+
.ruff_cache/
|
|
217
|
+
|
|
218
|
+
# PyPI configuration file
|
|
219
|
+
.pypirc
|
|
220
|
+
|
|
221
|
+
# Marimo
|
|
222
|
+
marimo/_static/
|
|
223
|
+
marimo/_lsp/
|
|
224
|
+
__marimo__/
|
|
225
|
+
|
|
226
|
+
# Streamlit
|
|
227
|
+
.streamlit/secrets.toml
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to Betteroff. Versions follow [semantic versioning](https://semver.org/). Add entries under Unreleased; `scripts/publish.sh` moves them under a dated version heading when you release.
|
|
4
|
+
|
|
5
|
+
## [Unreleased]
|
|
6
|
+
|
|
7
|
+
## [0.1.0] - 2026-10-12
|
|
8
|
+
|
|
9
|
+
First release.
|
|
10
|
+
|
|
11
|
+
- Catalog of 18 Surveys of Consumers tables in the historical three-category layout, searchable offline by id, table number, title, keywords and wording.
|
|
12
|
+
- `get` fetches, validates and caches Michigan's historical Excel files and exports tidy or wide CSV and JSON with a metadata sidecar. `--measure index` returns Michigan's index score.
|
|
13
|
+
- `chart` makes HTML, SVG, PNG, PDF and Vega-Lite charts with polarity colors, direct labels, monthly tooltips, trailing averages, NBER recession shading and explicit gaps for missing months.
|
|
14
|
+
- `run` rebuilds declared outputs from a TOML recipe and records the snapshot behind each one.
|
|
15
|
+
- Content-addressed snapshots with revision reports; failed or invalid refreshes never replace the last good snapshot.
|
|
16
|
+
- Exit codes 2, 3 and 4 for input, fetch and validation failures.
|
betteroff-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Matt Stiles
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
betteroff-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: betteroff
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Clean data and charts from the Michigan consumer surveys
|
|
5
|
+
Project-URL: Homepage, https://github.com/stiles/betteroff
|
|
6
|
+
Project-URL: Documentation, https://github.com/stiles/betteroff/tree/main/docs
|
|
7
|
+
Project-URL: Issues, https://github.com/stiles/betteroff/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/stiles/betteroff/blob/main/CHANGELOG.md
|
|
9
|
+
Author: Matt Stiles
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: cli,consumer sentiment,economics,journalism,survey,university of michigan
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Requires-Dist: httpx<1,>=0.27
|
|
26
|
+
Requires-Dist: pandas>=2.1
|
|
27
|
+
Requires-Dist: platformdirs>=4
|
|
28
|
+
Requires-Dist: rich>=13.7
|
|
29
|
+
Requires-Dist: typer>=0.15
|
|
30
|
+
Requires-Dist: xlrd>=2.0.1
|
|
31
|
+
Provides-Extra: charts
|
|
32
|
+
Requires-Dist: altair<7,>=6; extra == 'charts'
|
|
33
|
+
Requires-Dist: vl-convert-python<2,>=1.9; extra == 'charts'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# Betteroff
|
|
37
|
+
|
|
38
|
+
Clean data and charts from the Michigan consumer surveys.
|
|
39
|
+
|
|
40
|
+
Betteroff finds, downloads, validates, exports and charts the published monthly tables from the University of Michigan [Surveys of Consumers](https://data.sca.isr.umich.edu/). It keeps the question wording, response labels and source details attached to every file it writes, so a CSV or chart can be traced back to the exact download behind it.
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
betteroff search government
|
|
44
|
+
betteroff get government_policy --wide -o government_policy.csv
|
|
45
|
+
betteroff chart government_policy --rolling 12 --recessions -o government_policy.svg
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Betteroff is an independent project. It is not affiliated with or endorsed by the University of Michigan. See [Data use](#data-use) before publishing anything made with it.
|
|
49
|
+
|
|
50
|
+
## Install
|
|
51
|
+
|
|
52
|
+
Betteroff needs Python 3.11 or newer. The charts are an optional extra because they pull in Altair and vl-convert.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Command-line tool in its own environment, with charts
|
|
56
|
+
uv tool install 'betteroff[charts]'
|
|
57
|
+
|
|
58
|
+
# Try it without installing
|
|
59
|
+
uvx betteroff search housing
|
|
60
|
+
uvx --from 'betteroff[charts]' betteroff chart 41
|
|
61
|
+
|
|
62
|
+
# Python library in an analysis project or notebook environment
|
|
63
|
+
uv add 'betteroff[charts]'
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`pip install 'betteroff[charts]'` works too. A `uv tool` install doesn't make the module importable in a notebook; add it to the notebook's project for that.
|
|
67
|
+
|
|
68
|
+
## Quick start
|
|
69
|
+
|
|
70
|
+
Find a question. Search and list work offline because they read only the packaged catalog.
|
|
71
|
+
|
|
72
|
+
```console
|
|
73
|
+
$ betteroff search unemployment
|
|
74
|
+
Table Id Title
|
|
75
|
+
30 unemployment_expectations Expected change in unemployment during the next year
|
|
76
|
+
29 business_conditions_5_years Business conditions expected during the next 5 years
|
|
77
|
+
34 government_policy Opinions about the government's economic policy
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Read the question's wording, response categories and notes. Once data is cached, `describe` also shows the latest three months and a 24-month sparkline per response.
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
betteroff describe unemployment_expectations
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Get the data. In a terminal you see the latest 24 months; piped or written to a file you get every month.
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
betteroff get 30 # table in the terminal
|
|
90
|
+
betteroff get 30 > unemployment.csv # tidy CSV, one row per month and response
|
|
91
|
+
betteroff get 30 --wide -o unemployment_wide.csv # one row per month, for Datawrapper
|
|
92
|
+
betteroff get 30 --measure index -f json # Michigan's index score as JSON records
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Chart it.
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
betteroff chart 30 --open # unemployment_expectations.html
|
|
99
|
+
betteroff chart 30 --rolling 12 --recessions -o unemp.svg # editable vector file
|
|
100
|
+
betteroff chart 30 --start 2000 -o unemp.png # 2x PNG
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Table numbers and ids are interchangeable: `betteroff get 34` and `betteroff get government_policy` return the same data.
|
|
104
|
+
|
|
105
|
+
## Python
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
import betteroff as bo
|
|
109
|
+
|
|
110
|
+
bo.search('housing')
|
|
111
|
+
ds = bo.get('government_policy', refresh=True)
|
|
112
|
+
ds.data # tidy pandas DataFrame
|
|
113
|
+
ds.wide() # one row per month
|
|
114
|
+
ds.metadata # wording, source, snapshot, coverage, notes
|
|
115
|
+
chart = ds.chart(rolling=12, recessions=True) # a plain altair.LayerChart
|
|
116
|
+
chart.save('government_policy.html', inline=True)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
See the [Python API docs](https://github.com/stiles/betteroff/blob/main/docs/python.md).
|
|
120
|
+
|
|
121
|
+
## Supported tables
|
|
122
|
+
|
|
123
|
+
Every table in Michigan's catalog that uses the historical three-category layout, with one positive, one neutral and one negative response plus nonresponse where reported:
|
|
124
|
+
|
|
125
|
+
| Table | Id | Title |
|
|
126
|
+
| --- | --- | --- |
|
|
127
|
+
| 6 | `current_finances` | Current financial situation compared with a year ago |
|
|
128
|
+
| 8 | `expected_finances` | Expected change in financial situation in a year |
|
|
129
|
+
| 10 | `finances_vs_5_years_ago` | Current financial situation compared with 5 years ago |
|
|
130
|
+
| 11 | `expected_finances_5_years` | Expected change in financial situation in 5 years |
|
|
131
|
+
| 14 | `real_income_expectations` | Expected change in real household income during the next year |
|
|
132
|
+
| 19 | `retirement_chances` | Change in likelihood of comfortable retirement |
|
|
133
|
+
| 25 | `business_conditions_vs_year_ago` | Current business conditions compared with a year ago |
|
|
134
|
+
| 26 | `business_conditions_expected` | Expected change in business conditions in a year |
|
|
135
|
+
| 28 | `business_conditions_12_months` | Business conditions expected during the next year |
|
|
136
|
+
| 29 | `business_conditions_5_years` | Business conditions expected during the next 5 years |
|
|
137
|
+
| 30 | `unemployment_expectations` | Expected change in unemployment during the next year |
|
|
138
|
+
| 31 | `interest_rate_expectations` | Expected change in interest rates during the next year |
|
|
139
|
+
| 34 | `government_policy` | Opinions about the government's economic policy |
|
|
140
|
+
| 35 | `durables_buying_conditions` | Buying conditions for large household durables |
|
|
141
|
+
| 37 | `vehicle_buying_conditions` | Buying conditions for vehicles |
|
|
142
|
+
| 41 | `home_buying_conditions` | Buying conditions for houses |
|
|
143
|
+
| 43 | `home_selling_conditions` | Selling conditions for houses |
|
|
144
|
+
| 45 | `home_value_change` | Change in home values during the past year |
|
|
145
|
+
|
|
146
|
+
Tables with other layouts (the sentiment indexes, income and price distributions, probabilities, reasons for opinions and demographic breakdowns) aren't supported yet. All series cover all households.
|
|
147
|
+
|
|
148
|
+
## How it works
|
|
149
|
+
|
|
150
|
+
1. Betteroff reads Michigan's [tables page](https://data.sca.isr.umich.edu/tables.php), finds the current link to the table's historical Excel file and downloads it. Links carry a per-release key, so they are discovered fresh instead of guessed.
|
|
151
|
+
2. It checks the file is a real Excel workbook, not an access page or error text sent with HTTP 200, then parses it and checks the column headers against the catalog. Any unexpected or missing column stops the run with exit code 4.
|
|
152
|
+
3. It validates the values and saves the raw bytes in a content-addressed cache with a manifest. A failed download or validation never replaces the last good snapshot.
|
|
153
|
+
4. Later runs reuse the cache for 24 hours. `--refresh` forces a check; `--offline` never touches the network.
|
|
154
|
+
5. When a refresh brings new bytes, Betteroff compares them with the previous snapshot and reports new months, revised months and removed months.
|
|
155
|
+
|
|
156
|
+
**Latest month is not the same as retrieval time.** Michigan's detailed-data site updates after an embargo that ends four weeks after each month's final release, so the newest month here trails the headline number by a month or more. A refresh that finds no new month is working as intended.
|
|
157
|
+
|
|
158
|
+
More in the [data docs](https://github.com/stiles/betteroff/blob/main/docs/data.md).
|
|
159
|
+
|
|
160
|
+
## Outputs
|
|
161
|
+
|
|
162
|
+
| Command | Output |
|
|
163
|
+
| --- | --- |
|
|
164
|
+
| `get` in a terminal | Latest 24 months as a table |
|
|
165
|
+
| `get` piped | Tidy CSV on stdout; notices on stderr |
|
|
166
|
+
| `get -o FILE.csv` or `.json` | Tidy file, or wide with `--wide`, plus `FILE.csv.meta.json` |
|
|
167
|
+
| `chart -o FILE.html` | Self-contained HTML that works offline |
|
|
168
|
+
| `chart -o FILE.svg`, `.png`, `.pdf` | 16:9 static files; SVG text stays editable |
|
|
169
|
+
| `chart -o FILE.vl.json` | Vega-Lite spec with inline data for the Vega Editor or vega-embed |
|
|
170
|
+
| `run betteroff.toml` | Every output the recipe declares, plus `betteroff-run.json` |
|
|
171
|
+
|
|
172
|
+
Every file gets a metadata sidecar with the question wording, response mapping, source URL, retrieval time, snapshot hash, coverage, notes, source quirks and package versions. Betteroff refuses to overwrite a file unless you pass `--force`.
|
|
173
|
+
|
|
174
|
+
## Recipes
|
|
175
|
+
|
|
176
|
+
Save a workflow in TOML and rerun it with one command:
|
|
177
|
+
|
|
178
|
+
```toml
|
|
179
|
+
schema_version = 1
|
|
180
|
+
output_dir = 'output'
|
|
181
|
+
|
|
182
|
+
[[jobs]]
|
|
183
|
+
question = 'government_policy'
|
|
184
|
+
start = '2000-01-01'
|
|
185
|
+
data_formats = ['csv', 'json']
|
|
186
|
+
chart_formats = ['html', 'svg']
|
|
187
|
+
rolling = 12
|
|
188
|
+
recessions = true
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
betteroff run betteroff.toml --refresh
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
See the [recipe docs](https://github.com/stiles/betteroff/blob/main/docs/recipes.md).
|
|
196
|
+
|
|
197
|
+
## Exit codes
|
|
198
|
+
|
|
199
|
+
| Code | Meaning |
|
|
200
|
+
| --- | --- |
|
|
201
|
+
| 0 | Success |
|
|
202
|
+
| 2 | Invalid input: unknown id, bad option, format conflict, file exists |
|
|
203
|
+
| 3 | Fetch or access failure, or `--offline` with no saved snapshot |
|
|
204
|
+
| 4 | The source file no longer matches what the parser expects |
|
|
205
|
+
|
|
206
|
+
Errors print one line and a suggested fix. Add `--debug` before the command, or set `BETTEROFF_DEBUG=1`, for a full traceback.
|
|
207
|
+
|
|
208
|
+
## Environment
|
|
209
|
+
|
|
210
|
+
| Variable | Effect |
|
|
211
|
+
| --- | --- |
|
|
212
|
+
| `BETTEROFF_CACHE_DIR` | Cache location; defaults to the platform cache directory (`betteroff cache path`) |
|
|
213
|
+
| `BETTEROFF_DEBUG` | Show tracebacks |
|
|
214
|
+
| `NO_COLOR` | Disable color |
|
|
215
|
+
|
|
216
|
+
## Data use
|
|
217
|
+
|
|
218
|
+
Michigan's [usage agreement](https://data.sca.isr.umich.edu/agreement.php) lets you display, reformat and print the data for your organization's use with the attribution "University of Michigan, Survey Research Center, Surveys of Consumers." It bars reproducing, redistributing, publishing or broadcasting the data without written consent from the university.
|
|
219
|
+
|
|
220
|
+
Betteroff's MIT license covers the code only, not the data. Betteroff fetches data to your machine and never hosts or bundles it. Its tests use synthetic files. Getting permission for any publication is up to you; charts include the required attribution in their footer.
|
|
221
|
+
|
|
222
|
+
## Documentation
|
|
223
|
+
|
|
224
|
+
- [Command-line reference](https://github.com/stiles/betteroff/blob/main/docs/cli.md)
|
|
225
|
+
- [Python API](https://github.com/stiles/betteroff/blob/main/docs/python.md)
|
|
226
|
+
- [Data, metadata and caching](https://github.com/stiles/betteroff/blob/main/docs/data.md)
|
|
227
|
+
- [Charts](https://github.com/stiles/betteroff/blob/main/docs/charts.md)
|
|
228
|
+
- [Recipes](https://github.com/stiles/betteroff/blob/main/docs/recipes.md)
|
|
229
|
+
- [Releasing](https://github.com/stiles/betteroff/blob/main/docs/releasing.md)
|
|
230
|
+
- [Changelog](https://github.com/stiles/betteroff/blob/main/CHANGELOG.md)
|
|
231
|
+
|
|
232
|
+
## Development
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
git clone https://github.com/stiles/betteroff && cd betteroff
|
|
236
|
+
uv sync --all-extras
|
|
237
|
+
uv run pytest # offline tests
|
|
238
|
+
uv run pytest -m live # fetch every table from Michigan; run sparingly
|
|
239
|
+
uv run ruff check src tests && uv run ruff format --check src tests
|
|
240
|
+
uv run mypy
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Normal tests never touch the network. A scheduled GitHub Action runs the live check weekly and opens an issue if Michigan's files change.
|
|
244
|
+
|
|
245
|
+
## License
|
|
246
|
+
|
|
247
|
+
MIT for the code. The data belongs to the University of Michigan; see [Data use](#data-use).
|