{"id":14065069,"url":"https://github.com/Pytlicek/sheet2dict","last_synced_at":"2025-07-29T19:34:07.955Z","repository":{"id":39920767,"uuid":"336798785","full_name":"Pytlicek/sheet2dict","owner":"Pytlicek","description":"Simple XLSX and CSV to dictionary converter","archived":false,"fork":false,"pushed_at":"2024-07-10T09:22:14.000Z","size":1554,"stargazers_count":221,"open_issues_count":1,"forks_count":11,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-12-01T01:46:26.103Z","etag":null,"topics":["csv","dictionary-converter","excel","export","hacktoberfest","hacktoberfest-accepted","python","python3","spreadsheet","worksheet","xlsx"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/sheet2dict/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Pytlicek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"ko_fi":"pytlicek"}},"created_at":"2021-02-07T13:53:31.000Z","updated_at":"2024-10-26T12:36:39.000Z","dependencies_parsed_at":"2024-06-19T09:17:24.030Z","dependency_job_id":"de4c5156-8984-453d-82a6-94074f7f2e95","html_url":"https://github.com/Pytlicek/sheet2dict","commit_stats":{"total_commits":81,"total_committers":6,"mean_commits":13.5,"dds":0.0864197530864198,"last_synced_commit":"5a7b7ea4f0d7f7af7fed3e3bf702ea02c3b2faaa"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pytlicek%2Fsheet2dict","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pytlicek%2Fsheet2dict/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pytlicek%2Fsheet2dict/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pytlicek%2Fsheet2dict/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pytlicek","download_url":"https://codeload.github.com/Pytlicek/sheet2dict/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228046047,"owners_count":17861086,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csv","dictionary-converter","excel","export","hacktoberfest","hacktoberfest-accepted","python","python3","spreadsheet","worksheet","xlsx"],"created_at":"2024-08-13T07:04:16.532Z","updated_at":"2024-12-04T04:30:42.992Z","avatar_url":"https://github.com/Pytlicek.png","language":"Python","funding_links":["https://ko-fi.com/pytlicek"],"categories":["Python"],"sub_categories":[],"readme":"![Test Python package](https://github.com/Pytlicek/sheet2dict/workflows/Test%20Python%20package/badge.svg) \n[![codecov](https://codecov.io/gh/Pytlicek/sheet2dict/branch/main/graph/badge.svg?token=JL4BOX947I)](https://codecov.io/gh/Pytlicek/sheet2dict) \n![Upload Python Package to PyPI](https://github.com/Pytlicek/sheet2dict/workflows/Upload%20Python%20Package%20to%20PyPI/badge.svg) \n![PythonVersions](https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8%20%7C%203.9%20%7C%203.10%20%7C%203.11-blue) \n[![Sourcery](https://img.shields.io/badge/Sourcery-enabled-brightgreen)](https://sourcery.ai) \n[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black) \n[![Snyk](https://snyk-widget.herokuapp.com/badge/pip/sheet2dict/badge.svg)](https://snyk.io/advisor/python/sheet2dict) \n[![Downloads](https://pepy.tech/badge/sheet2dict)](https://pepy.tech/project/sheet2dict) \n[![Twitter Follow](https://img.shields.io/twitter/follow/Pytlicek?color=1DA1F2\u0026logo=twitter\u0026style=flat)](https://twitter.com/Pytlicek)\n\n\n# sheet2dict\nA simple XLSX/CSV reader - to dictionary converter  \n\n## Installing\nTo install the package from pip, first run:\n```bash\npython3 -m pip install --no-cache-dir sheet2dict\n```\n\nRequired pip packages for sheet2doc: csv, openpyxl\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/Pytlicek/sheet2dict/main/img/sheet2dict.gif?raw=true\"/\u003e\u003c/p\u003e\n\n## Usage\nThis library has 2 main features: reading a spreadsheet files and converting them to array of python dictionaries.  \n\n### - XLSX\nUse `xlsx_to_dict()` method  when converting form spreadsheets.  \nSupported file formats for spreadsheets are: .xlsx,.xlsm,.xltx,.xltm  \nSpreadsheets with multiple worksheets are supported. If no sheet is specified, the active sheet is selected. If there is only one sheet, it is considered active.\n\n```python3\n# Import the library\nfrom sheet2dict import Worksheet\n\n# Create an object\nws = Worksheet()\n\n# Convert active sheet (without specifying sheet name)\nws.xlsx_to_dict(path='inventory.xlsx')\n\n# Convert the 'Main Warehouse' sheet of the 'inventory.xslx' spreadsheet file.\nws.xlsx_to_dict(path='inventory.xlsx', select_sheet='Main Warehouse')\n\n# object.header returns first row with the data in a spreadsheet \nprint(ws.header)\n\n# object.sheet_items returns converted rows as dictionaries in the array \nprint(ws.sheet_items)\n\n```\n\nYou can parse data when worksheet is an object\n\n```python3\n# Import the library\nfrom sheet2dict import Worksheet\n\n# Example: read spreadsheet as object\npath = 'inventory.xlsx'\nxlsx_file = open(path, 'rb')\nxlsx_file = BytesIO(xlsx_file.read())\n\n# Parse spreadsheet from object\nws = Worksheet()\nws.xlsx_to_dict(path=xlsx_file)\nprint(ws.header)\n\n```\n\n### - CSV\nUse `csv_to_dict()` method  when converting form csv.  \nCSV is a format with many variations, better handle encodings and delimiters on user side and not within module itself.\n\n```python3\n# Import the library\nfrom sheet2dict import Worksheet\n\n# Create an object\nws = Worksheet()\n\n# Read CSV file\ncsv_file = open('inventory.csv', 'r', encoding='utf-8-sig')\n\n# Convert \nws.csv_to_dict(csv_file=csv_file, delimiter=';')\n\n# object.header returns first row with the data in a spreadsheet \nprint(ws.header)\n\n# object.sheet_items returns converted rows as dictionaries in the array \nprint(ws.sheet_items)\n```\n\n### - Other functions\nWorksheet **object.header** returns first row with the data in a spreadsheet \n```python\nPython 3.9.1\n[Clang 12.0.0 (clang-1200.0.32.28)] on darwin\n\u003e\u003e\u003e from sheet2dict import Worksheet\n\u003e\u003e\u003e ws = Worksheet()\n\u003e\u003e\u003e ws.xlsx_to_dict(path=\"inventory.xlsx\")\n\n\u003e\u003e\u003e ws.header\n{'country': 'SK', 'city': 'Bratislava', 'citizens': '400000', 'random_field': 'cc'}\n```\n\nWorksheet **object.sanitize_sheet_items** removes None or empty dictionary keys from `sheet_items`\n```python\n\u003e\u003e\u003e from sheet2dict import Worksheet\n\u003e\u003e\u003e ws = Worksheet()\n\u003e\u003e\u003e ws.xlsx_to_dict(path=\"inventory.xlsx\")\n\n\u003e\u003e\u003e ws.sheet_items\n[\n  {'country': 'CZ', 'city': 'Prague', 'citizens': '600000', None: '22', 'random_field': 'cc'},\n  {'country': 'UK', 'city': 'London', 'citizens': '2000000', None: '33', 'random_field': 'cc'}\n]\n\n\u003e\u003e\u003e ws.sanitize_sheet_items\n[\n  {'country': 'CZ', 'city': 'Prague', 'citizens': '600000', 'random_field': 'cc'},\n  {'country': 'UK', 'city': 'London', 'citizens': '2000000', 'random_field': 'cc'}\n]\n```\n\n# Contributing and Code of Conduct  \n### Contributing to sheet2dict  \nAs an open source project, sheet2dict welcomes contributions of many forms.  \nPlease read and follow our [Contributing to sheet2dict](CONTRIBUTING.md)  \n\n**Contributors:**\n- Thanks to 白一百 (bái-yī-bǎi) for making sheet2dict work with multi-sheet Excel files.\n\n### Code of Conduct  \nAs a contributor, you can help us keep the sheet2dict project open and inclusive.  \nPlease read and follow our [Code of Conduct](CODE_OF_CONDUCT.md)  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPytlicek%2Fsheet2dict","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPytlicek%2Fsheet2dict","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPytlicek%2Fsheet2dict/lists"}