Skip to main content

A .xlsx parser

Project description

xlsxparse

xlsxparse is a Python command-line application that extracts cell references from an Excel file and outputs their locations to a JSON file. The tool provides two main commands:

  • create: Parses an Excel (.xlsx) file for references and exports them to a JSON file.
  • search: Searches the generated JSON file for specific references.

Installation

You can install xlsxparse via pip:

pip install xlsxparse-joeypas

Ensure you have Python 3.8+ installed.

Usage

Create Command

Extracts references from an Excel file and saves them to a JSON file.

xlsxparse create <xlsx_file> [--sheet <sheet_name>] --output <json_file>

Parameters:

  • <xlsx_file>: Path to the Excel file.
  • --sheet <sheet_name> (optional): Name of the specific sheet to parse. If omitted, all sheets are parsed.
  • --output <json_file>: (optional): Path to save the extracted references in JSON format.

Example:

xlsxparse create data.xlsx --sheet Sheet1 --output refs.json

Search Command

Searches the JSON file for specific references.

xlsxparse search [OPTIONS] STRING [FILE]

Arguments:

  • STRING (required): String to search for.
  • FILE (optional): Path to the file. Defaults to output.json.

Options:

  • --stype [metric|sheet-metric|ref-file|ref-file-sheet] (default: metric): Search type.
  • --help: Show help message and exit.

Example:

xlsxparse search "Book2.xlsx, Sheet2" refs.json --stype ref-file-sheet

Output Format

The output JSON file follows this structure:

[
  {
    "Sheet": "Sheet1",
    "Metric": [
      "Test",
      "Three"
    ],
    "Cell": "B4",
    "Formula": "=B2+B3",
    "References": [
      {
        "sheet": "Sheet1",
        "cell": "B2"
      },
      {
        "sheet": "Sheet1",
        "cell": "B3"
      }
    ]
  },
  {
    "Sheet": "Sheet2",
    "Metric": [
      null,
      null
    ],
    "Cell": "A2",
    "Formula": "=SUM(30,[1]Sheet1!D12)",
    "References": [
      {
        "file": "Book2.xlsx",
        "sheet": "Sheet1",
        "cell": "D12"
      }
    ]
  }
]

Dependencies

  • Python 3.8+
  • openpyxl
  • typer

Contributing

  1. Fork the repository.
  2. Create a new branch (feature-branch).
  3. Commit your changes.
  4. Push to your branch and open a Pull Request.

License

This project is licensed under the MIT License.

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

xlsxparse_joeypas-0.1.2.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

xlsxparse_joeypas-0.1.2-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xlsxparse_joeypas-0.1.2.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for xlsxparse_joeypas-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4581850f3b006552e51cac56279cafeb22859613f1a1c7c857c1be5813824dad
MD5 de716b956d544733f819cc0722346d47
BLAKE2b-256 8e844d6b9f2af4f23f8f709a7d5f5167b1a52ac10cfc70482f62c3d4984d8ef8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlsxparse_joeypas-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 06e02fc736ea2924aaf2a6b06ff6c6c8133c7aea1a301ad2a68db64576d7afd9
MD5 7419db4d52167f3f6ff35b429242ea09
BLAKE2b-256 e0233390c6a7bfab35c05c75ede4979bf605e11340fd9ad17b9d8126a3aff9b3

See more details on using hashes here.

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