Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dimastbk/python-calamine
Python binding for Rust's library for reading excel and odf file - calamine.
https://github.com/dimastbk/python-calamine
excel ods pandas python spreadsheet xls xlsb xlsx
Last synced: 11 days ago
JSON representation
Python binding for Rust's library for reading excel and odf file - calamine.
- Host: GitHub
- URL: https://github.com/dimastbk/python-calamine
- Owner: dimastbk
- License: mit
- Created: 2021-08-29T12:21:16.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-11-04T12:18:48.000Z (12 days ago)
- Last Synced: 2024-11-04T12:41:11.339Z (12 days ago)
- Topics: excel, ods, pandas, python, spreadsheet, xls, xlsb, xlsx
- Language: Python
- Homepage: https://pypi.org/project/python-calamine/
- Size: 308 KB
- Stars: 271
- Watchers: 4
- Forks: 5
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# python-calamine
[![PyPI - Version](https://img.shields.io/pypi/v/python-calamine)](https://pypi.org/project/python-calamine/)
[![Conda Version](https://img.shields.io/conda/vn/conda-forge/python-calamine.svg)](https://anaconda.org/conda-forge/python-calamine)
![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Fdimastbk%2Fpython-calamine%2Fmaster%2Fpyproject.toml)Python binding for beautiful Rust's library for reading excel and odf file - [calamine](https://github.com/tafia/calamine).
### Is used
* [calamine](https://github.com/tafia/calamine)
* [pyo3](https://github.com/PyO3/pyo3)
* [maturin](https://github.com/PyO3/maturin)### Installation
Pypi:
```
pip install python-calamine
```
Conda:
```
conda install -c conda-forge python-calamine
```### Example
```python
from python_calamine import CalamineWorkbookworkbook = CalamineWorkbook.from_path("file.xlsx")
workbook.sheet_names
# ["Sheet1", "Sheet2"]workbook.get_sheet_by_name("Sheet1").to_python()
# [
# ["1", "2", "3", "4", "5", "6", "7"],
# ["1", "2", "3", "4", "5", "6", "7"],
# ["1", "2", "3", "4", "5", "6", "7"],
# ]
```By default, calamine skips empty rows/cols before data. For suppress this behaviour, set `skip_empty_area` to `False`.
```python
from python_calamine import CalamineWorkbookworkbook = CalamineWorkbook.from_path("file.xlsx").get_sheet_by_name("Sheet1").to_python(skip_empty_area=False)
# [
# [", ", ", ", ", ", "],
# ["1", "2", "3", "4", "5", "6", "7"],
# ["1", "2", "3", "4", "5", "6", "7"],
# ["1", "2", "3", "4", "5", "6", "7"],
# ]
```Also, you can use monkeypatch for pandas for use this library as engine in `read_excel()` (only pandas 2.0 and 2.1 are supported).
Pandas 2.2 and above have built-in support of python-calamine.
```python
from pandas import read_excel
from python_calamine.pandas import pandas_monkeypatchpandas_monkeypatch()
read_excel("file.xlsx", engine="calamine")
# 1 2 3 4 5 6 7
# 0 1 2 3 4 5 6 7
# 1 1 2 3 4 5 6 7
```Also, you can find additional examples in [tests](https://github.com/dimastbk/python-calamine/blob/master/tests/test_base.py).