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 Excel Reference Extractor 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.7+
  • openpyxl

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.1.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.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xlsxparse_joeypas-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 fc79a3489dd43678801efd7d79cc326599238c6c70267c958d80bd03cf956e43
MD5 d98d948f62cb6bc02e10df53877ecb22
BLAKE2b-256 1da92af3779a146aa3869108c1979d4d46f3b96d2ba00bdb1ec02302e73e03da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlsxparse_joeypas-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 076170fc754d06fd6ac745c9e689986c04bc7441105b99609147b2fd012c7052
MD5 d4a09ab8ea8cd2bb0bb16f683f69a768
BLAKE2b-256 0d2c70445bf77afb39a57ba9e8863616760bce441ebac9aac2e8f41ad01d5880

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