Skip to main content

Read XLSX, XLS and CSV files with a uniform interface Read XLSX, XLS and CSV files with a uniform interface

Project description

#+TITLE: tabular-reader

* tabular_reader

** Description
A module that maps information from each row in XLSX, XLS, or CSV
files to a ~SimpleNamespace~ object, providing a uniform interface
across different spreadsheet and data formats. Similar to Python's
native [[https://docs.python.org/3/library/csv.html#csv.DictReader][csv.DictReader]] but with support for multiple file types.

** Installing
#+begin_src bash
pip install tabular-reader
#+end_src

** Examples

*** Basic usage with XLSX
#+begin_src python
from tabular_reader import TabularReader

reader = TabularReader("names.xlsx", worksheet="Sheet1")
for row in reader:
print(row.first_name, row.last_name)
#+end_src

Output:
#+begin_src
Boris Johnson
Donald Trump
Mark Rutte
#+end_src

*** Reading CSV files
#+begin_src python
from tabular_reader import TabularReader

reader = TabularReader("data.csv")
for row in reader:
print(row.email, row.phone)
#+end_src

*** Reading XLS files
#+begin_src python
from tabular_reader import TabularReader

reader = TabularReader("legacy_data.xls")
for row in reader:
print(row.id, row.name)
#+end_src

** Custom fieldnames
You can specify fieldnames manually:

#+begin_src python
reader = TabularReader(
"data.xlsx",
fieldnames=["id", "email", "username"]
)
for row in reader:
print(row.id, row.email)
#+end_src

** Skip blank lines
Filter out empty rows:

#+begin_src python
reader = TabularReader(
"data.csv",
skip_blank_lines=True
)
for row in reader:
print(row)
#+end_src

** Keyword arguments

*** For Excel files (XLSX/XLS)
Pass any ~openpyxl.load_workbook~ keyword arguments:

#+begin_src python
reader = TabularReader(
"names.xlsx",
worksheet="Sheet1",
read_only=False,
keep_vba=False,
data_only=False,
keep_links=True
)
#+end_src

*** For CSV files
Pass any ~csv.reader~ keyword arguments:

#+begin_src python
reader = TabularReader(
"data.csv",
delimiter=";",
quotechar='"',
encoding="utf-8"
)
#+end_src

** Features
- Automatic format detection by file extension
- Empty column filtering (only processes columns with headers)
- Uniform interface across XLSX, XLS, and CSV
- ~SimpleNamespace~ objects with attribute access (~row.field_name~)
- Python 3.6 - 3.14 support

** Supported formats
| Format | Extension | Status |
|--------|-----------|-------------|
| Excel | .xlsx | ✓ Supported |
| Excel | .xls | ✓ Supported |
| CSV | .csv | ✓ Supported |

** Acknowledgements
- [[https://openpyxl.readthedocs.io/][openpyxl]]
- [[https://docs.python.org/3/library/csv.html][csv]] - Python's standard library

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tabular_reader-0.1.3.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tabular_reader-0.1.3-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file tabular_reader-0.1.3.tar.gz.

File metadata

  • Download URL: tabular_reader-0.1.3.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tabular_reader-0.1.3.tar.gz
Algorithm Hash digest
SHA256 825d610fa5379e2d5b6a37567742bfd2b5fecae19ca92d4c4836a86c0c0a9aef
MD5 d397b1080d7716f3a86035f9db950318
BLAKE2b-256 a0c69398f35a347a84fde710df435642f051c4dbe5ab69a414745bf7e46438c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for tabular_reader-0.1.3.tar.gz:

Publisher: workflow.yml on arkhan/tabular-reader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tabular_reader-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: tabular_reader-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tabular_reader-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b03c18e738b54f3233e204e0eafd9f539edd0129127051f6b0d20a9e2a8cd428
MD5 3bdf2a2da35897ba2e6c0ebc61051cd7
BLAKE2b-256 5d788e12da74c678e7677c9c15680804ced352d2de29a8a7a023b9efa0e2b75d

See more details on using hashes here.

Provenance

The following attestation bundles were made for tabular_reader-0.1.3-py3-none-any.whl:

Publisher: workflow.yml on arkhan/tabular-reader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page