Metadata-Version: 2.4
Name: excel-validator
Version: 0.9.5
Summary: Validation of template based Excel files
Author-email: Matthijs Brouwer <matthijs.brouwer@wur.nl>
License: MIT License
        
        Copyright (c) 2024 EU H2020 AGENT project
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/matthijsbrouwer/excel-validator
Classifier: Topic :: Internet :: Proxy Servers
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Classifier: Programming Language :: Python :: 3.11
Classifier: Operating System :: OS Independent
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: attrs==25.4.0
Requires-Dist: cachelib==0.13.0
Requires-Dist: Flask==3.1.2
Requires-Dist: flask_session==0.8.0
Requires-Dist: frictionless==5.18.1
Requires-Dist: func_timeout==4.3.5
Requires-Dist: jsonschema==4.25.1
Requires-Dist: numpy==2.3.4
Requires-Dist: openpyxl==3.1.5
Requires-Dist: pandas==2.3.3
Requires-Dist: Requests==2.32.5
Requires-Dist: rich==14.2.0
Requires-Dist: tqdm==4.67.1
Requires-Dist: waitress==3.0.2
Dynamic: license-file

# Excel Validator

Excel Validator is a Python package designed to validate Excel files (.xlsx) based on configured schemas. The tool ensures your Excel files adhere to specified schemas and generates detailed reports in case of validation errors. Built on the robust Frictionless library, Excel Validator also allows for dynamic schema creation, where fields are included based on row data from other sheets.

## Features

* Validate Excel files against predefined schemas.
* Generate detailed reports highlighting any validation issues.
* Dynamic schema creation based on data from other sheets.
* Easy integration with your existing data processing workflows.
* Built on top of the [Frictionless library](https://framework.frictionlessdata.io/) for reliable and extensible validation.
* Integrated webservice for online validation.

## Installation

The software requires at least Python version 3.11. It is recommended to create and activate a dedicated conda environment for the installation of this software:

```
conda create -n excel-validator python=3.11
conda activate excel-validator
```

Now you can install Excel Validator via pip:

```
pip install excel-validator
```

## Usage

Once installed, the software can be directly used from the command line interface. Use the `--help` option to get additional instructions on how to use it:

```
usage: excel-validator [-h] {validate,configuration,webservice} ...
```

Three different commands can be used, each with its own options:

* **validate**: validates the provided Excel file
* **configuration**: creates an initial configuration based on the provided Excel file
* **webservice**: starts a web service for online validation of Excel files

### Examples

Validation of Excel file:
```
# validate filename.xlsx using miappe template
excel-validator validate --config miappe filename.xlsx

# validate filename.xlsx using miappe template and show report
excel-validator validate --config miappe --report filename.xlsx

# validate filename.xlsx using miappe template and store report as filename.txt
excel-validator validate --config miappe filename.xlsx --createTextReport

# validate filename.xlsx using custom template in location/configuration/custom
excel-validator validate --config location/configuration/custom filename.xlsx
```

Create initial validation configuration for Excel file:
```
# create configuration filename.xlsx and store in location/configuration/initial
excel-validator configuration filename.xlsx --output location/configuration/initial
```

Start webservice for validation Excel files:
```
# start webservice and create new configuration file config.ini if it doesn't exist
excel-validator webservice

# start webservice and using a specific configuration file
excel-validator webservice --config configuration/webservice/config.ini
```

### Python

The package can also imported directly in your Python application:

```
import excel_validator

#optionally enable logging
import logging
logging.basicConfig(format="%(asctime)s | %(levelname)s: %(message)s", datefmt="%m-%d-%y %H:%M:%S")
logging.getLogger("excel_validator.validator").setLevel(logging.INFO)

excelFilename = "/path/to/filename.xlsx"
configFilename = "/path/to/specific/configuration"
validation = excel_validator.Validate(excelFilename,configFilename)
```

A configuration for [MIAPPE](https://www.miappe.org/) is already included in the software and can be used with:

```
configFilename = excel_validator.Validate.getConfigFilename("miappe")
```

The `validation` object contains the status (`validation.valid`) and can be used to create a report if the Excel file is found to be invalid:

```
validation.createMarkdownReport("report.md")
print(validation.createTextReport())
```

---
This software has been developed for the [AGENT](https://www.agent-project.eu/) project

