{ "info": { "author": "Alistair Miles", "author_email": "alimanfoo@googlemail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "============\ncsvvalidator\n============\n\nThis module provides some simple utilities for validating data contained in CSV \nfiles, or other similar data sources.\n\nThe source code for this module lives at: \n\n https://github.com/alimanfoo/csvvalidator\n\nPlease report any bugs or feature requests via the issue tracker there.\n\nInstallation\n============\n\nThis module is registered with the Python package index, so you can do::\n\n $ easy_install csvvalidator\n\n... or download from http://pypi.python.org/pypi/csvvalidator and\ninstall in the usual way::\n\n $ python setup.py install\n\nIf you want the bleeding edge, clone the source code repository::\n\n $ git clone git://github.com/alimanfoo/csvvalidator.git\n $ cd csvvalidator\n $ python setup.py install\n\nUsage\n=====\n\nThe `CSVValidator` class is the foundation for all validator objects that are \ncapable of validating CSV data. \n\nYou can use the CSVValidator class to dynamically construct a validator, e.g.::\n\n import sys\n import csv\n from csvvalidator import *\n\n field_names = (\n 'study_id', \n 'patient_id', \n 'gender', \n 'age_years', \n 'age_months',\n 'date_inclusion'\n )\n\n validator = CSVValidator(field_names)\n \n # basic header and record length checks\n validator.add_header_check('EX1', 'bad header')\n validator.add_record_length_check('EX2', 'unexpected record length')\n \n # some simple value checks\n validator.add_value_check('study_id', int, \n 'EX3', 'study id must be an integer')\n validator.add_value_check('patient_id', int, \n 'EX4', 'patient id must be an integer')\n validator.add_value_check('gender', enumeration('M', 'F'), \n 'EX5', 'invalid gender')\n validator.add_value_check('age_years', number_range_inclusive(0, 120, int), \n 'EX6', 'invalid age in years')\n validator.add_value_check('date_inclusion', datetime_string('%Y-%m-%d'),\n 'EX7', 'invalid date')\n \n # a more complicated record check\n def check_age_variables(r):\n age_years = int(r['age_years'])\n age_months = int(r['age_months'])\n valid = (age_months >= age_years * 12 and \n age_months % age_years < 12)\n if not valid:\n raise RecordError('EX8', 'invalid age variables')\n validator.add_record_check(check_age_variables)\n\n # validate the data and write problems to stdout \n data = csv.reader('/path/to/data.csv', delimiter='\\t')\n problems = validator.validate(data)\n write_problems(problems, sys.stdout)\n\nFor more complex use cases you can also sub-class `CSVValidator` to define \nre-usable validator classes for specific data sources.\n\nFor a complete account of all of the functionality available from this module, \nsee the example.py and tests.py modules in the source code repository.\n\nNotes\n=====\n\nNote that the `csvvalidator` module is intended to be used in combination with \nthe standard Python `csv` module. The `csvvalidator` module **will not** \nvalidate the *syntax* of a CSV file. Rather, the `csvvalidator` module can be \nused to validate any source of row-oriented data, such as is provided by a \n`csv.reader` object.\n\nI.e., if you want to validate data from a CSV file, you have to first construct \na CSV reader using the standard Python `csv` module, specifying the appropriate \ndialect, and then pass the CSV reader as the source of data to either the \n`CSVValidator.validate` or the `CSVValidator.ivalidate` method.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/alimanfoo/csvvalidator", "keywords": null, "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "csvvalidator", "package_url": "https://pypi.org/project/csvvalidator/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/csvvalidator/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/alimanfoo/csvvalidator" }, "release_url": "https://pypi.org/project/csvvalidator/1.2/", "requires_dist": null, "requires_python": null, "summary": "A simple library for validating data contained in CSV files or similar row-oriented data sources.", "version": "1.2" }, "last_serial": 788602, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "a5dd7367f807735782a1ab5f945616a5", "sha256": "80648f3a8295ca16e27f81a0e515e55fa1f8b4fc92fd6c70f1300f358ab4d8dc" }, "downloads": -1, "filename": "csvvalidator-1.0.tar.gz", "has_sig": false, "md5_digest": "a5dd7367f807735782a1ab5f945616a5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8316, "upload_time": "2011-07-21T18:31:17", "url": "https://files.pythonhosted.org/packages/37/2f/9666b5c1620dd2b531463ab8a538f9de39a504566999558e0a59827b4a83/csvvalidator-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "e0f38c900b59102fa16631305ba4f3aa", "sha256": "b5b74626ea43ec3298f1ccf37239e0fb13e28abd82e6b5ac3cf5026bf4876abb" }, "downloads": -1, "filename": "csvvalidator-1.1.tar.gz", "has_sig": false, "md5_digest": "e0f38c900b59102fa16631305ba4f3aa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9941, "upload_time": "2011-07-27T16:19:10", "url": "https://files.pythonhosted.org/packages/45/47/688c21813764254a8aea84185e9f91dcbd5bb14d29d5e3e2e9c4f21e70dd/csvvalidator-1.1.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "a6fab92e0dc6f22fd87356d8d8294e4f", "sha256": "f6ad3f3e28aaea78ffb73a670e9712b4d62152a7873ce7a5f9a2ef171eb7fdab" }, "downloads": -1, "filename": "csvvalidator-1.1.1.linux-i686.exe", "has_sig": false, "md5_digest": "a6fab92e0dc6f22fd87356d8d8294e4f", "packagetype": "bdist_wininst", "python_version": "any", "requires_python": null, "size": 74285, "upload_time": "2012-04-24T23:59:52", "url": "https://files.pythonhosted.org/packages/32/ff/72c075b05fd37a297418c78296fcbd5ebdd244e5f52a35d83db22279c6b4/csvvalidator-1.1.1.linux-i686.exe" }, { "comment_text": "", "digests": { "md5": "b8a7846202e9476716021c1fb53f61e4", "sha256": "f9f1af171524d8aed0f6a7c3e59f84b091e9545bd040fa8d0e9719bbc80d8c91" }, "downloads": -1, "filename": "csvvalidator-1.1.1.tar.gz", "has_sig": false, "md5_digest": "b8a7846202e9476716021c1fb53f61e4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8896, "upload_time": "2012-04-24T23:59:49", "url": "https://files.pythonhosted.org/packages/e5/db/1c9890f21cbde9a9d8ea14a754206cbb16d37e492cd301176368aa8a2c8b/csvvalidator-1.1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "71f9466c06111c7248509c8c48386b2e", "sha256": "f1f222993589f9d8f8d83088d0bf80475462e5fa848baf920d0c03c03690c37e" }, "downloads": -1, "filename": "csvvalidator-1.2.tar.gz", "has_sig": false, "md5_digest": "71f9466c06111c7248509c8c48386b2e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9940, "upload_time": "2013-05-16T13:33:46", "url": "https://files.pythonhosted.org/packages/22/cd/0b1a28226ed8cefb15bb0024a2adb6b6018b7248e0a75320ffeac316e6fb/csvvalidator-1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "71f9466c06111c7248509c8c48386b2e", "sha256": "f1f222993589f9d8f8d83088d0bf80475462e5fa848baf920d0c03c03690c37e" }, "downloads": -1, "filename": "csvvalidator-1.2.tar.gz", "has_sig": false, "md5_digest": "71f9466c06111c7248509c8c48386b2e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9940, "upload_time": "2013-05-16T13:33:46", "url": "https://files.pythonhosted.org/packages/22/cd/0b1a28226ed8cefb15bb0024a2adb6b6018b7248e0a75320ffeac316e6fb/csvvalidator-1.2.tar.gz" } ] }