Giter Site home page Giter Site logo

mkesicki / excel_validator Goto Github PK

View Code? Open in Web Editor NEW
26.0 5.0 17.0 98 KB

Python script to validate data in Excel files

License: MIT License

Python 92.71% Batchfile 0.48% Dockerfile 6.81%
python excel validator validation xlsx spreadsheet invalid-cells python-script excel-validator excelvalidate

excel_validator's Introduction

Excel Validator

Excel Validator is used to validate different constraints of excel column through a Validation rules stored in YAML files.

constraints to be checked : - Base Validator - Choice Validator - Condition Validator - Country Validator - DateTime Validator - Email Validator - Excel Date Validator - Length Validator - NotBlank Validator - Regex Validator - Type Validator

Requirements

  1. Python 3
  2. All necessary python libraries are listed in requirements.txt

Script parameters

$ python excel_validator.py  -h
usage: excel_validator.py [-h] [--errors errors] config file sheetName tmpDir

Mark validation errors in Excel sheet.

positional arguments:
  config           Path to YAML config file
  file             Path to excel sheet file
  sheetName        Excel Sheet Name
  tmpDir           Temporary directory path

optional arguments:
  -h, --help           Print help description
  --errors             Print errors messages without generating excel file with errors
  --no-file-size-limit Switch off file size limit. Use with care

Example usage

usage for example/excel.xlsx file


/PATH/excel_validator>python excel_validator.py "example/example.yml" /PATH/excel.xlsx "Example" "/tmp" --errors=true
Get validation config example/example.yml
Validate Excel Sheet Example
Parse Excel file
Processing |################################| 5/5
Found 22 error(s)
Processing |#                               | 1/22Broken Excel cell: C2
Processing |##                              | 2/22Broken Excel cell: F2
Processing |####                            | 3/22Broken Excel cell: H2
Processing |#####                           | 4/22Broken Excel cell: M2
Processing |#######                         | 5/22Broken Excel cell: A3
Processing |########                        | 6/22Broken Excel cell: D3
Processing |##########                      | 7/22Broken Excel cell: F3
Processing |###########                     | 8/22Broken Excel cell: G3
Processing |#############                   | 9/22Broken Excel cell: H3
Processing |##############                  | 10/22Broken Excel cell: I3
Processing |################                | 11/22Broken Excel cell: K3
Processing |#################               | 12/22Broken Excel cell: M3
Processing |##################              | 13/22Broken Excel cell: A4
Processing |####################            | 14/22Broken Excel cell: E4
Processing |#####################           | 15/22Broken Excel cell: F4
Processing |#######################         | 16/22Broken Excel cell: H4
Processing |########################        | 17/22Broken Excel cell: K4
Processing |##########################      | 18/22Broken Excel cell: M4
Processing |###########################     | 19/22Broken Excel cell: A5
Processing |#############################   | 20/22Broken Excel cell: B5
Processing |##############################  | 21/22Broken Excel cell: J5
Processing |################################| 22/22Broken Excel cell: M5

[[Save file: /tmp/errors_2017-04-25_1493102119_excel.xlsx]]
Validation errors store in: [[/tmp/errors_2017-04-25_1493102119_excel.xlsx]]

/PATH/excel_validator>pause
Press any key to continue . . .

Windows user bonus

validate.bat contains example usage (same as in this documentation) of script. In Windows you can Drag & Drop Excel file on validate.bat script and it should execute validation. Of course you should change content of this file according to your needs.

excel_validator's People

Contributors

mkesicki avatar tiagofilipesilva avatar upgreydd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

excel_validator's Issues

Excludes columns are still validated

Exclude columns are still validated if the columns have blanks though it states that #default validator is used for not excluded columns for which no other validation rule is set
Code: excludes: ["L","M"]

Only if I remove the below code, the column validations excluded

default:
- NotBlank:
message: Value can not be blank

Name/Type of validator is set wrong if column has more than one validator

It is always set for first validator for column example:

        C:
            - Type:
                type: integer
                message: "Message"
                trim: true
                
        - Conditional:
                message: "Message"
                fieldB: "C"
                operator: "lambda c, d: (False if (c > d) else True)"
                trim: true 
        D:
            - Type:
                type: integer
                message: "Message"
                trim: true

in this case conditional validator will be not set

Python3

Dear,
I was testing your script but it seems to fail with python 3.
Dict variables are not supported.
I'm getting errors on type = settings.keys()[0]

Addressing error file size limitation

sys.exit("Invalid file is too big to generate annotated Excel file")

Hi,

I think this is a great tool, but there seems to be a limitation regarding the binary size of the error Excel file.

If I try to run against an input file that is between 76 -- 100 megabits Excel file, I receive an error saying that the output error file is too large and thus cannot be created.

As a user (with sufficient resource) my expectation is for a file to be generated.
Does anyone more versed in the code of the solution and/or supporting libraries provide me with enlightenment on how to bypass this situation?

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.