Skip to main content

A python library for reading and writing Excel files, converting between xlsx and dict or text

Project description

xlsx2dict

A Python library for reading and writing Excel files, converting between xlsx and dict or text.

Installation

pip install xlsx2dict

Usage

Python API

from xlsx2dict import sheets, read, read_dict, write, write_dict, xlsx2text

# List sheet names
sheet_names = sheets("example.xlsx")

# Read a sheet as list of lists
data = read("example.xlsx", sheet_name="Sheet1")

# Read a sheet as ordered dict (keyed by row number)
d = read_dict("example.xlsx", sheet_name="Sheet1")
d = read_dict("example.xlsx", sheet_name="Sheet1", head_rows=2)       # multi-row headers
d = read_dict("example.xlsx", sheet_name="Sheet1", save_list=True)    # include raw row as __list__
d = read_dict("example.xlsx", sheet_name="Sheet1", key_map={"Old": "New"})  # rename columns

# Write list of lists to xlsx
write([["Name", "Age"], ["Alice", 30]], "output.xlsx", sheet_name="Data")

# Write dict to multi-sheet xlsx
write_dict("output.xlsx", {
    "Sheet1": [["Name", "Age"], ["Alice", 30]],
    "Sheet2": [["City", "Country"], ["Paris", "France"]],
})

# Convert xlsx to formatted text
xlsx2text("example.xlsx")                    # prints all sheets
xlsx2text("example.xlsx", index=1)           # prints first sheet
xlsx2text("example.xlsx", output_file="out.txt")  # write to file

CLI

# Convert all sheets to console
xlsx2text example.xlsx

# Convert a specific sheet
xlsx2text example.xlsx -i 1

# Save output to file
xlsx2text example.xlsx -o output.txt

License

MIT

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

xlsx2dict-0.1.2.tar.gz (24.4 kB view details)

Uploaded Source

Built Distribution

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

xlsx2dict-0.1.2-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file xlsx2dict-0.1.2.tar.gz.

File metadata

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

File hashes

Hashes for xlsx2dict-0.1.2.tar.gz
Algorithm Hash digest
SHA256 049817d2d07d26975596b89988e1cf0bf59b1e159f16bf0bbf8a272f12c1b16a
MD5 5d35631aaa5b19db90f4102437252dee
BLAKE2b-256 0589703a517d2844aee67ebabb49d3b4da28574a940a2c1099b37f883c7737d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for xlsx2dict-0.1.2.tar.gz:

Publisher: publish.yml on huanghhhz/xlsx2dict

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

File details

Details for the file xlsx2dict-0.1.2-py3-none-any.whl.

File metadata

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

File hashes

Hashes for xlsx2dict-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dc65954ae9f31c8afc16411c4fa0a58cac810130cd76b4efdd735e08b495b4af
MD5 5fb0c1720bd6c690c2a445bd80a2bb64
BLAKE2b-256 067c9d5267a7659fa619a19e75bd21dee6a9632a2b51b618979968852ac6932e

See more details on using hashes here.

Provenance

The following attestation bundles were made for xlsx2dict-0.1.2-py3-none-any.whl:

Publisher: publish.yml on huanghhhz/xlsx2dict

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