| Name | metaprinter JSON |
| Version |
0.2.3
JSON |
| download |
| home_page | None |
| Summary | print and extract spss metadata |
| upload_time | 2025-09-10 04:50:33 |
| maintainer | None |
| docs_url | None |
| author | Albert Li |
| requires_python | >=3.11 |
| license | None |
| keywords |
|
| VCS |
|
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# SPSS Metadata Printer 📊
Easy-to-use Python package for extracting, viewing, and exporting metadata from SPSS files with beautiful formatting.
## ✨ Features
- 📋 **Pretty-print comprehensive SPSS metadata** to console
- 💾 **Export metadata summaries** to text files automatically saved to Downloads
- 📄 **Extract metadata dictionary to JSON** for programmatic access and archival
- 📊 **Detailed variable information** including labels, types, and value mappings
- 🎨 **Beautiful table formatting** with configurable width and display options
## 🚀 Quick Start
### Installation
```bash
pip install metaprinter
```
Or using uv:
```bash
uv add metaprinter
```
### Basic Usage
```python
import pyreadstat
from metaprinter import print_metadata, export_metadata, extract_metadict
# Load your SPSS file
df, meta = pyreadstat.read_sav('data.sav')
# Display beautiful metadata summary inside a notebook
print_summary = print_metadata(df, meta)
# Export to Downloads/metadata_summary.txt
export_summary = export_metadata(df, meta)
# Extract metadata to JSON (Downloads/meta_dictionary.json)
extract_metadict(meta)
```
**Output Preview:**
```
============================================================
SPSS FILE METADATA
============================================================
File encoding : 'UTF-8'
Number of cols : 25
Number of rows : 100
Table name : 'Table'
File label : 'Customer Satisfaction Survey'
Notes : 'Notes'
VARIABLE METADATA
============================================================
┌───────────────┬─────────┬──────────┬───────────┬──────────────┬─────────────────────┬─────────────────────┐
│ column ┆ dtype ┆ column_n ┆ n_uniques ┆ n_categories ┆ column_label ┆ value_labels │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ str ┆ str ┆ i64 ┆ i64 ┆ i64 ┆ str ┆ str │
╞═══════════════╪═════════╪══════════╪═══════════╪══════════════╪═════════════════════╪═════════════════════╡
│ respondent_id ┆ Int64 ┆ 1547 ┆ 1547 ┆ 0 ┆ Respondent ID ┆ │
│ satisfaction ┆ Int64 ┆ 1523 ┆ 5 ┆ 5 ┆ Satisfaction Level ┆ { │
│ ┆ ┆ ┆ ┆ ┆ ┆ "1": "Very Low", │
│ ┆ ┆ ┆ ┆ ┆ ┆ "2": "Low", │
│ ┆ ┆ ┆ ┆ ┆ ┆ "3": "Neutral", │
│ ┆ ┆ ┆ ┆ ┆ ┆ "4": "High", │
│ ┆ ┆ ┆ ┆ ┆ ┆ "5": "Very High" │
│ ┆ ┆ ┆ ┆ ┆ ┆ } │
│ age ┆ Int64 ┆ 1534 ┆ 6 ┆ 6 ┆ Age Group Category ┆ { │
│ ┆ ┆ ┆ ┆ ┆ ┆ "1": "18-25", │
│ ┆ ┆ ┆ ┆ ┆ ┆ "2": "26-35", │
│ ┆ ┆ ┆ ┆ ┆ ┆ "3": "36-45", │
│ ┆ ┆ ┆ ┆ ┆ ┆ "4": "46-55", │
│ ┆ ┆ ┆ ┆ ┆ ┆ "5": "56-65", │
│ ┆ ┆ ┆ ┆ ┆ ┆ "6": "65+" │
│ ┆ ┆ ┆ ┆ ┆ ┆ } │
│ ... ┆ ... ┆ ... ┆ ... ┆ ... ┆ ... ┆ ... │
└───────────────┴─────────┴──────────┴───────────┴──────────────┴─────────────────────┴─────────────────────┘
```
## 📖 API Reference
### `print_metadata(df, meta, show_all_columns=True, max_width=222, include_all=False)`
Print a comprehensive metadata summary for SPSS data loaded with pyreadstat.
**Parameters:**
- `df`: DataFrame containing the SPSS data (Pandas or Polars)
- `meta`: Metadata object from `pyreadstat.read_sav()`
- `show_all_columns`: Whether to show all columns without truncation (default: True, optional)
- `max_width`: Maximum table width in characters (default: 222, optional)
- `include_all`: Whether to include all available metadata fields (default: False, optional)
---
### `export_metadata(df, meta, filename=None, show_all_columns=True, max_width=222, include_all=False)`
Export SPSS metadata summary to a text file in the Downloads folder.
**Parameters:**
- `df`: DataFrame containing the SPSS data (Pandas or Polars)
- `meta`: Metadata object from `pyreadstat.read_sav()`
- `filename`: Custom filename without extension (default: "metadata_summary")
- `show_all_columns`: Whether to show all columns without truncation (default: True, optional)
- `max_width`: Maximum table width in characters (default: 222, optional)
- `include_all`: Whether to include all available metadata fields (default: False, optional)
---
### `extract_metadict(meta, include_all=False, output_path=None)`
Extract metadata dictionary from pyreadstat meta object and save as JSON.
**Parameters:**
- `meta`: Metadata object from `pyreadstat.read_sav()`
- `include_all`: Whether to include all metadata fields or just essential ones (default: False, optional)
- `output_path`: Custom file path for JSON output (must end with .json). If None, saves to Downloads/meta_dictionary.json (default: None, optional)
**Example JSON Output (basic):**
```json
{
"General Information": {
"Notes": "Survey conducted in 2024",
"Creation Time": "2024-01-15 10:30:00",
"File Encoding": "UTF-8",
"Number of Columns": 25,
"Number of Rows": 100,
"Table Name": "Table",
"File Label": "Customer Satisfaction Survey"
},
"Variable Information": {
"Column Names to Labels": {
"respondent_id": "Respondent ID",
"satisfaction": "Satisfaction Level",
"age": "Age Group Category"
},
"Variable Value Labels": {
"satisfaction": {
"1": "Very Low",
"2": "Low",
"3": "Neutral",
"4": "High",
"5": "Very High"
}
}
}
}
```
---
## 📋 Requirements
- Python >=3.11
- pyreadstat >=1.3.0
- polars >=1.3.0
- pandas >=2.3.0
## 📝 License
MIT License - see LICENSE file for details
## 🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Raw data
{
"_id": null,
"home_page": null,
"name": "metaprinter",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": null,
"author": "Albert Li",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/8d/97/38b0fe47a2d465e9da0a71c455cf7d49d0167afe259299ef972227873f2c/metaprinter-0.2.3.tar.gz",
"platform": null,
"description": "# SPSS Metadata Printer \ud83d\udcca\r\n\r\nEasy-to-use Python package for extracting, viewing, and exporting metadata from SPSS files with beautiful formatting.\r\n\r\n## \u2728 Features\r\n\r\n- \ud83d\udccb **Pretty-print comprehensive SPSS metadata** to console\r\n- \ud83d\udcbe **Export metadata summaries** to text files automatically saved to Downloads\r\n- \ud83d\udcc4 **Extract metadata dictionary to JSON** for programmatic access and archival\r\n- \ud83d\udcca **Detailed variable information** including labels, types, and value mappings\r\n- \ud83c\udfa8 **Beautiful table formatting** with configurable width and display options\r\n\r\n## \ud83d\ude80 Quick Start\r\n\r\n### Installation\r\n\r\n```bash\r\npip install metaprinter\r\n```\r\n\r\nOr using uv:\r\n\r\n```bash\r\nuv add metaprinter\r\n```\r\n\r\n### Basic Usage\r\n\r\n```python\r\nimport pyreadstat\r\nfrom metaprinter import print_metadata, export_metadata, extract_metadict\r\n\r\n# Load your SPSS file\r\ndf, meta = pyreadstat.read_sav('data.sav')\r\n\r\n# Display beautiful metadata summary inside a notebook\r\nprint_summary = print_metadata(df, meta)\r\n\r\n# Export to Downloads/metadata_summary.txt\r\nexport_summary = export_metadata(df, meta)\r\n\r\n# Extract metadata to JSON (Downloads/meta_dictionary.json)\r\nextract_metadict(meta)\r\n```\r\n\r\n**Output Preview:**\r\n```\r\n============================================================\r\nSPSS FILE METADATA\r\n============================================================\r\nFile encoding : 'UTF-8'\r\nNumber of cols : 25\r\nNumber of rows : 100\r\nTable name : 'Table'\r\nFile label : 'Customer Satisfaction Survey'\r\nNotes : 'Notes'\r\n\r\nVARIABLE METADATA\r\n============================================================\r\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\r\n\u2502 column \u2506 dtype \u2506 column_n \u2506 n_uniques \u2506 n_categories \u2506 column_label \u2506 value_labels \u2502\r\n\u2502 --- \u2506 --- \u2506 --- \u2506 --- \u2506 --- \u2506 --- \u2506 --- \u2502\r\n\u2502 str \u2506 str \u2506 i64 \u2506 i64 \u2506 i64 \u2506 str \u2506 str \u2502\r\n\u255e\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2561\r\n\u2502 respondent_id \u2506 Int64 \u2506 1547 \u2506 1547 \u2506 0 \u2506 Respondent ID \u2506 \u2502\r\n\u2502 satisfaction \u2506 Int64 \u2506 1523 \u2506 5 \u2506 5 \u2506 Satisfaction Level \u2506 { \u2502\r\n\u2502 \u2506 \u2506 \u2506 \u2506 \u2506 \u2506 \"1\": \"Very Low\", \u2502\r\n\u2502 \u2506 \u2506 \u2506 \u2506 \u2506 \u2506 \"2\": \"Low\", \u2502\r\n\u2502 \u2506 \u2506 \u2506 \u2506 \u2506 \u2506 \"3\": \"Neutral\", \u2502\r\n\u2502 \u2506 \u2506 \u2506 \u2506 \u2506 \u2506 \"4\": \"High\", \u2502\r\n\u2502 \u2506 \u2506 \u2506 \u2506 \u2506 \u2506 \"5\": \"Very High\" \u2502\r\n\u2502 \u2506 \u2506 \u2506 \u2506 \u2506 \u2506 } \u2502\r\n\u2502 age \u2506 Int64 \u2506 1534 \u2506 6 \u2506 6 \u2506 Age Group Category \u2506 { \u2502\r\n\u2502 \u2506 \u2506 \u2506 \u2506 \u2506 \u2506 \"1\": \"18-25\", \u2502\r\n\u2502 \u2506 \u2506 \u2506 \u2506 \u2506 \u2506 \"2\": \"26-35\", \u2502\r\n\u2502 \u2506 \u2506 \u2506 \u2506 \u2506 \u2506 \"3\": \"36-45\", \u2502\r\n\u2502 \u2506 \u2506 \u2506 \u2506 \u2506 \u2506 \"4\": \"46-55\", \u2502\r\n\u2502 \u2506 \u2506 \u2506 \u2506 \u2506 \u2506 \"5\": \"56-65\", \u2502\r\n\u2502 \u2506 \u2506 \u2506 \u2506 \u2506 \u2506 \"6\": \"65+\" \u2502\r\n\u2502 \u2506 \u2506 \u2506 \u2506 \u2506 \u2506 } \u2502\r\n\u2502 ... \u2506 ... \u2506 ... \u2506 ... \u2506 ... \u2506 ... \u2506 ... \u2502\r\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\r\n```\r\n\r\n## \ud83d\udcd6 API Reference\r\n\r\n### `print_metadata(df, meta, show_all_columns=True, max_width=222, include_all=False)`\r\n\r\nPrint a comprehensive metadata summary for SPSS data loaded with pyreadstat.\r\n\r\n**Parameters:**\r\n- `df`: DataFrame containing the SPSS data (Pandas or Polars)\r\n- `meta`: Metadata object from `pyreadstat.read_sav()`\r\n- `show_all_columns`: Whether to show all columns without truncation (default: True, optional)\r\n- `max_width`: Maximum table width in characters (default: 222, optional)\r\n- `include_all`: Whether to include all available metadata fields (default: False, optional)\r\n\r\n\r\n---\r\n\r\n### `export_metadata(df, meta, filename=None, show_all_columns=True, max_width=222, include_all=False)`\r\n\r\nExport SPSS metadata summary to a text file in the Downloads folder.\r\n\r\n**Parameters:**\r\n- `df`: DataFrame containing the SPSS data (Pandas or Polars)\r\n- `meta`: Metadata object from `pyreadstat.read_sav()`\r\n- `filename`: Custom filename without extension (default: \"metadata_summary\")\r\n- `show_all_columns`: Whether to show all columns without truncation (default: True, optional)\r\n- `max_width`: Maximum table width in characters (default: 222, optional)\r\n- `include_all`: Whether to include all available metadata fields (default: False, optional)\r\n\r\n\r\n---\r\n\r\n### `extract_metadict(meta, include_all=False, output_path=None)`\r\n\r\nExtract metadata dictionary from pyreadstat meta object and save as JSON.\r\n\r\n**Parameters:**\r\n- `meta`: Metadata object from `pyreadstat.read_sav()`\r\n- `include_all`: Whether to include all metadata fields or just essential ones (default: False, optional)\r\n- `output_path`: Custom file path for JSON output (must end with .json). If None, saves to Downloads/meta_dictionary.json (default: None, optional)\r\n\r\n**Example JSON Output (basic):**\r\n```json\r\n{\r\n \"General Information\": {\r\n \"Notes\": \"Survey conducted in 2024\",\r\n \"Creation Time\": \"2024-01-15 10:30:00\",\r\n \"File Encoding\": \"UTF-8\",\r\n \"Number of Columns\": 25,\r\n \"Number of Rows\": 100,\r\n \"Table Name\": \"Table\",\r\n \"File Label\": \"Customer Satisfaction Survey\"\r\n },\r\n \"Variable Information\": {\r\n \"Column Names to Labels\": {\r\n \"respondent_id\": \"Respondent ID\",\r\n \"satisfaction\": \"Satisfaction Level\",\r\n \"age\": \"Age Group Category\"\r\n },\r\n \"Variable Value Labels\": {\r\n \"satisfaction\": {\r\n \"1\": \"Very Low\",\r\n \"2\": \"Low\",\r\n \"3\": \"Neutral\",\r\n \"4\": \"High\",\r\n \"5\": \"Very High\"\r\n }\r\n }\r\n }\r\n}\r\n```\r\n\r\n---\r\n\r\n## \ud83d\udccb Requirements\r\n\r\n- Python >=3.11\r\n- pyreadstat >=1.3.0\r\n- polars >=1.3.0\r\n- pandas >=2.3.0\r\n\r\n## \ud83d\udcdd License\r\n\r\nMIT License - see LICENSE file for details\r\n\r\n## \ud83e\udd1d Contributing\r\n\r\nContributions are welcome! Please feel free to submit a Pull Request.",
"bugtrack_url": null,
"license": null,
"summary": "print and extract spss metadata",
"version": "0.2.3",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "2ed6f341f978729d10e72abd075672751ec90b4596cda44640832c1ebb6b7141",
"md5": "23db0b5a8d502d27d94ad9ddde6a8400",
"sha256": "2a6cb8fdbdb44c441b140628180d1544909269e620483ae538010ee09f5a6ac7"
},
"downloads": -1,
"filename": "metaprinter-0.2.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "23db0b5a8d502d27d94ad9ddde6a8400",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 7553,
"upload_time": "2025-09-10T04:50:32",
"upload_time_iso_8601": "2025-09-10T04:50:32.323531Z",
"url": "https://files.pythonhosted.org/packages/2e/d6/f341f978729d10e72abd075672751ec90b4596cda44640832c1ebb6b7141/metaprinter-0.2.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "8d9738b0fe47a2d465e9da0a71c455cf7d49d0167afe259299ef972227873f2c",
"md5": "bfa02a7e993ff74d4dc410f437b84840",
"sha256": "4ed7ed4741944e874e504c4f484da133fe59706109fe9399d0a88f9711c8c511"
},
"downloads": -1,
"filename": "metaprinter-0.2.3.tar.gz",
"has_sig": false,
"md5_digest": "bfa02a7e993ff74d4dc410f437b84840",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 6080,
"upload_time": "2025-09-10T04:50:33",
"upload_time_iso_8601": "2025-09-10T04:50:33.293074Z",
"url": "https://files.pythonhosted.org/packages/8d/97/38b0fe47a2d465e9da0a71c455cf7d49d0167afe259299ef972227873f2c/metaprinter-0.2.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-10 04:50:33",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "metaprinter"
}