survy 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.
Files changed (34) hide show
  1. survy-0.1.0/LICENSE +21 -0
  2. survy-0.1.0/PKG-INFO +208 -0
  3. survy-0.1.0/README.md +188 -0
  4. survy-0.1.0/pyproject.toml +33 -0
  5. survy-0.1.0/setup.cfg +4 -0
  6. survy-0.1.0/src/survy/__init__.py +27 -0
  7. survy-0.1.0/src/survy/analyze/__init__.py +4 -0
  8. survy-0.1.0/src/survy/analyze/crosstab/__init__.py +0 -0
  9. survy-0.1.0/src/survy/analyze/crosstab/_utils.py +306 -0
  10. survy-0.1.0/src/survy/analyze/crosstab/functions.py +71 -0
  11. survy-0.1.0/src/survy/errors.py +22 -0
  12. survy-0.1.0/src/survy/io/__init__.py +2 -0
  13. survy-0.1.0/src/survy/io/csv.py +128 -0
  14. survy-0.1.0/src/survy/io/excel.py +128 -0
  15. survy-0.1.0/src/survy/io/json.py +70 -0
  16. survy-0.1.0/src/survy/io/polars.py +147 -0
  17. survy-0.1.0/src/survy/io/spss.py +40 -0
  18. survy-0.1.0/src/survy/separators.py +3 -0
  19. survy-0.1.0/src/survy/survey/__init__.py +0 -0
  20. survy-0.1.0/src/survy/survey/survey.py +230 -0
  21. survy-0.1.0/src/survy/utils/functions.py +123 -0
  22. survy-0.1.0/src/survy/utils/spss.py +241 -0
  23. survy-0.1.0/src/survy/variable/_utils.py +24 -0
  24. survy-0.1.0/src/survy/variable/strategies/__init__.py +0 -0
  25. survy-0.1.0/src/survy/variable/strategies/base_strategy.py +60 -0
  26. survy-0.1.0/src/survy/variable/strategies/multiselect_strategy.py +149 -0
  27. survy-0.1.0/src/survy/variable/strategies/number_strategy.py +90 -0
  28. survy-0.1.0/src/survy/variable/strategies/select_strategy.py +101 -0
  29. survy-0.1.0/src/survy/variable/variable.py +254 -0
  30. survy-0.1.0/src/survy.egg-info/PKG-INFO +208 -0
  31. survy-0.1.0/src/survy.egg-info/SOURCES.txt +32 -0
  32. survy-0.1.0/src/survy.egg-info/dependency_links.txt +1 -0
  33. survy-0.1.0/src/survy.egg-info/requires.txt +9 -0
  34. survy-0.1.0/src/survy.egg-info/top_level.txt +1 -0
survy-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ha Hoang Hao
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.
survy-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,208 @@
1
+ Metadata-Version: 2.4
2
+ Name: survy
3
+ Version: 0.1.0
4
+ Summary: Process, transform and analyze survey-format data with clean and simple API.
5
+ Author-email: Ha Hoang Hao <hhhao.vn@gmail.com>
6
+ Project-URL: Homepage, https://github.com/hoanghaoha/survy
7
+ Project-URL: Repository, https://github.com/hoanghaoha/survy
8
+ Requires-Python: >=3.12
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: polars[excel]>=1.37.1
12
+ Requires-Dist: numpy>2.0.0
13
+ Requires-Dist: pyreadstat>1.3.0
14
+ Requires-Dist: statsmodels>=0.14.0
15
+ Provides-Extra: dev
16
+ Requires-Dist: pytest; extra == "dev"
17
+ Requires-Dist: ruff; extra == "dev"
18
+ Requires-Dist: coverage; extra == "dev"
19
+ Dynamic: license-file
20
+
21
+ # survy
22
+
23
+ [![PyPI version](https://img.shields.io/pypi/v/survy.svg)](https://pypi.org/project/survy/)
24
+ [![License](https://img.shields.io/pypi/l/survy.svg)](LICENSE)
25
+ [![Python](https://img.shields.io/pypi/pyversions/survy.svg)](https://pypi.org/project/survy/)
26
+ [![CI](https://github.com/hoanghaoha/survy/actions/workflows/ci.yml/badge.svg)](https://github.com/hoanghaoha/survy/actions)
27
+
28
+ **Process, transform, and analyze survey-format data with a clean and simple API.**
29
+
30
+ ---
31
+
32
+ ## 📦 Overview
33
+
34
+ `survy` is a lightweight Python library built for working efficiently with survey data.
35
+ It simplifies the full workflow—from raw data ingestion to transformation and analysis—while preserving survey-specific structures like multiselect questions.
36
+
37
+ ---
38
+
39
+ ## ✨ Features
40
+
41
+ * 🔹 Multiselect as a first-class concept
42
+ * 🔹 Read & write multiple formats: CSV, Excel, JSON, SPSS, etc.
43
+ * 🔹 Clean, minimal, and expressive API
44
+ * 🔹 Built-in tools for validation, tracking, and analysis
45
+
46
+ ---
47
+
48
+ ## 🚀 Installation
49
+
50
+ ```bash
51
+ pip install survy
52
+ ```
53
+
54
+ ---
55
+
56
+ ## ⚡ Quick Demo
57
+
58
+ ### Sample data
59
+
60
+ `data.csv`
61
+ ```csv
62
+ id,Q1,Q2_1,Q2_2,Q2_3
63
+ 1,a,a,b,
64
+ 2,b,a,,c
65
+ 3,a,,b,c
66
+ ```
67
+
68
+ `data_compact.csv`
69
+ ```csv
70
+ id,Q1,Q2
71
+ 1,a,a;b
72
+ 2,b,a
73
+ 3,a,b;c
74
+ ```
75
+
76
+ ---
77
+
78
+ ### Load and analyze
79
+
80
+ ```python
81
+ import survy
82
+
83
+ # Load dataset with compact multiselect column
84
+ survey = survy.read_csv("data.csv")
85
+ #or
86
+ survey = survy.read_csv(
87
+ "data_compact.csv",
88
+ compact_ids=["Q2"],
89
+ compact_separator=";"
90
+ )
91
+
92
+ # Inspect variable
93
+ q1 = survey["Q1"]
94
+ print(q1.frequencies)
95
+
96
+ # Crosstab analysis
97
+ crosstab = survy.crosstab(survey["Q1"], survey["Q2"])
98
+ print(crosstab)
99
+ ```
100
+
101
+ ---
102
+
103
+ ## 📥 Usage
104
+
105
+ ### Load data
106
+
107
+ ```python
108
+ survey = survy.read_csv("data.csv")
109
+ ```
110
+
111
+ With compact multiselect:
112
+
113
+ ```python
114
+ survey = survy.read_csv(
115
+ "data.csv",
116
+ compact_ids=["Q2"],
117
+ compact_separator=";"
118
+ )
119
+ ```
120
+
121
+ ---
122
+
123
+ ### Get DataFrame
124
+
125
+ ```python
126
+ survey.get_df(select_dtype="text", multiselect_dtype="compact")
127
+ ```
128
+
129
+ ---
130
+
131
+ ### Work with variables
132
+
133
+ ```python
134
+ q1 = survey["Q1"]
135
+
136
+ print(q1.vtype)
137
+ print(q1.value_indices)
138
+ print(q1.base)
139
+ print(q1.frequencies)
140
+ ```
141
+
142
+ ---
143
+
144
+ ### Update variables
145
+
146
+ ```python
147
+ q1.label = "Question 1"
148
+ q1.value_indices = {"b": 1, "a": 2}
149
+ ```
150
+
151
+ Batch update:
152
+
153
+ ```python
154
+ survey.update([
155
+ {
156
+ "id": "Q1",
157
+ "label": "Question 1",
158
+ "value_indices": {"b": 1, "a": 2}
159
+ }
160
+ ])
161
+ ```
162
+
163
+ ---
164
+
165
+ ### Export
166
+
167
+ ```python
168
+ survey.to_csv("output.csv")
169
+ survey.to_spss("output.sav")
170
+ ```
171
+
172
+ ---
173
+
174
+ ### Analyze
175
+
176
+ ```python
177
+ crosstab = survy.crosstab(survey["Q1"], survey["Q2"])
178
+ print(crosstab)
179
+ ```
180
+
181
+ ---
182
+
183
+ ## 🧠 Design Philosophy
184
+
185
+ * Keep survey logic explicit (variables, labels, value mappings)
186
+ * Treat multiselect questions as a core data type
187
+ * Provide a clean abstraction over high-performance data processing
188
+
189
+ ---
190
+
191
+ ## 🤝 Contributing
192
+
193
+ Contributions are welcome!
194
+ Feel free to open issues or submit pull requests.
195
+
196
+ ---
197
+
198
+ ## 📄 License
199
+
200
+ MIT License
201
+
202
+ ---
203
+
204
+ ## 🔗 References
205
+
206
+ * Powered by **Polars** for fast data processing
207
+
208
+ ---
survy-0.1.0/README.md ADDED
@@ -0,0 +1,188 @@
1
+ # survy
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/survy.svg)](https://pypi.org/project/survy/)
4
+ [![License](https://img.shields.io/pypi/l/survy.svg)](LICENSE)
5
+ [![Python](https://img.shields.io/pypi/pyversions/survy.svg)](https://pypi.org/project/survy/)
6
+ [![CI](https://github.com/hoanghaoha/survy/actions/workflows/ci.yml/badge.svg)](https://github.com/hoanghaoha/survy/actions)
7
+
8
+ **Process, transform, and analyze survey-format data with a clean and simple API.**
9
+
10
+ ---
11
+
12
+ ## 📦 Overview
13
+
14
+ `survy` is a lightweight Python library built for working efficiently with survey data.
15
+ It simplifies the full workflow—from raw data ingestion to transformation and analysis—while preserving survey-specific structures like multiselect questions.
16
+
17
+ ---
18
+
19
+ ## ✨ Features
20
+
21
+ * 🔹 Multiselect as a first-class concept
22
+ * 🔹 Read & write multiple formats: CSV, Excel, JSON, SPSS, etc.
23
+ * 🔹 Clean, minimal, and expressive API
24
+ * 🔹 Built-in tools for validation, tracking, and analysis
25
+
26
+ ---
27
+
28
+ ## 🚀 Installation
29
+
30
+ ```bash
31
+ pip install survy
32
+ ```
33
+
34
+ ---
35
+
36
+ ## ⚡ Quick Demo
37
+
38
+ ### Sample data
39
+
40
+ `data.csv`
41
+ ```csv
42
+ id,Q1,Q2_1,Q2_2,Q2_3
43
+ 1,a,a,b,
44
+ 2,b,a,,c
45
+ 3,a,,b,c
46
+ ```
47
+
48
+ `data_compact.csv`
49
+ ```csv
50
+ id,Q1,Q2
51
+ 1,a,a;b
52
+ 2,b,a
53
+ 3,a,b;c
54
+ ```
55
+
56
+ ---
57
+
58
+ ### Load and analyze
59
+
60
+ ```python
61
+ import survy
62
+
63
+ # Load dataset with compact multiselect column
64
+ survey = survy.read_csv("data.csv")
65
+ #or
66
+ survey = survy.read_csv(
67
+ "data_compact.csv",
68
+ compact_ids=["Q2"],
69
+ compact_separator=";"
70
+ )
71
+
72
+ # Inspect variable
73
+ q1 = survey["Q1"]
74
+ print(q1.frequencies)
75
+
76
+ # Crosstab analysis
77
+ crosstab = survy.crosstab(survey["Q1"], survey["Q2"])
78
+ print(crosstab)
79
+ ```
80
+
81
+ ---
82
+
83
+ ## 📥 Usage
84
+
85
+ ### Load data
86
+
87
+ ```python
88
+ survey = survy.read_csv("data.csv")
89
+ ```
90
+
91
+ With compact multiselect:
92
+
93
+ ```python
94
+ survey = survy.read_csv(
95
+ "data.csv",
96
+ compact_ids=["Q2"],
97
+ compact_separator=";"
98
+ )
99
+ ```
100
+
101
+ ---
102
+
103
+ ### Get DataFrame
104
+
105
+ ```python
106
+ survey.get_df(select_dtype="text", multiselect_dtype="compact")
107
+ ```
108
+
109
+ ---
110
+
111
+ ### Work with variables
112
+
113
+ ```python
114
+ q1 = survey["Q1"]
115
+
116
+ print(q1.vtype)
117
+ print(q1.value_indices)
118
+ print(q1.base)
119
+ print(q1.frequencies)
120
+ ```
121
+
122
+ ---
123
+
124
+ ### Update variables
125
+
126
+ ```python
127
+ q1.label = "Question 1"
128
+ q1.value_indices = {"b": 1, "a": 2}
129
+ ```
130
+
131
+ Batch update:
132
+
133
+ ```python
134
+ survey.update([
135
+ {
136
+ "id": "Q1",
137
+ "label": "Question 1",
138
+ "value_indices": {"b": 1, "a": 2}
139
+ }
140
+ ])
141
+ ```
142
+
143
+ ---
144
+
145
+ ### Export
146
+
147
+ ```python
148
+ survey.to_csv("output.csv")
149
+ survey.to_spss("output.sav")
150
+ ```
151
+
152
+ ---
153
+
154
+ ### Analyze
155
+
156
+ ```python
157
+ crosstab = survy.crosstab(survey["Q1"], survey["Q2"])
158
+ print(crosstab)
159
+ ```
160
+
161
+ ---
162
+
163
+ ## 🧠 Design Philosophy
164
+
165
+ * Keep survey logic explicit (variables, labels, value mappings)
166
+ * Treat multiselect questions as a core data type
167
+ * Provide a clean abstraction over high-performance data processing
168
+
169
+ ---
170
+
171
+ ## 🤝 Contributing
172
+
173
+ Contributions are welcome!
174
+ Feel free to open issues or submit pull requests.
175
+
176
+ ---
177
+
178
+ ## 📄 License
179
+
180
+ MIT License
181
+
182
+ ---
183
+
184
+ ## 🔗 References
185
+
186
+ * Powered by **Polars** for fast data processing
187
+
188
+ ---
@@ -0,0 +1,33 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "survy"
7
+ version = "0.1.0"
8
+ description = "Process, transform and analyze survey-format data with clean and simple API."
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ dependencies = [
12
+ "polars[excel]>=1.37.1",
13
+ "numpy>2.0.0",
14
+ "pyreadstat>1.3.0",
15
+ "statsmodels>=0.14.0",
16
+ ]
17
+ authors = [{ name = "Ha Hoang Hao", email = "hhhao.vn@gmail.com" }]
18
+
19
+ [project.optional-dependencies]
20
+ dev = ["pytest", "ruff", "coverage"]
21
+
22
+ [project.urls]
23
+ Homepage = "https://github.com/hoanghaoha/survy"
24
+ Repository = "https://github.com/hoanghaoha/survy"
25
+
26
+ [tool.setuptools.packages.find]
27
+ where = ["src"]
28
+
29
+ [tool.pytest.ini_options]
30
+ testpaths = ["tests"]
31
+
32
+ [tool.coverage.run]
33
+ source = ["src/surpy"]
survy-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,27 @@
1
+ from survy.io.polars import read_polars
2
+ from survy.io.csv import read_csv, to_csv
3
+ from survy.io.excel import read_excel, to_excel
4
+ from survy.io.json import read_json, to_json
5
+ from survy.io.spss import to_spss
6
+
7
+
8
+ from survy.survey.survey import Survey
9
+ from survy.variable.variable import Variable, VarType
10
+
11
+ from survy.analyze.crosstab.functions import crosstab
12
+
13
+
14
+ __all__ = [
15
+ "read_polars",
16
+ "read_csv",
17
+ "read_excel",
18
+ "read_json",
19
+ "to_csv",
20
+ "to_excel",
21
+ "to_json",
22
+ "to_spss",
23
+ "Survey",
24
+ "Variable",
25
+ "VarType",
26
+ "crosstab",
27
+ ]
@@ -0,0 +1,4 @@
1
+ from survy.analyze.crosstab.functions import crosstab
2
+
3
+
4
+ __all__ = ["crosstab"]
File without changes