{ "info": { "author": "Cameron Simpson", "author_email": "cs@cskk.id.au", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Utility functions for CSV files.\n\nIn python 2 the stdlib CSV reader reads 8 bit byte data and returns str objects;\nthese need to be decoded into unicode objects.\nIn python 3 the stdlib CSV reader reads an open text file and returns str\nobjects (== unicode).\nSo we provide `csv_reader()` generators to yield rows containing unicode.\n\n## Function `csv_import(fp, class_name=None, column_names=None, computed=None, preprocess=None, mixin=None, **kw)`\n\nRead CSV data where the first row contains column headers.\nReturns a row namedtuple factory and an iterable of instances.\n\nParameters:\n* `fp`: a file object containing CSV data, or the name of such a file\n* `class_name`: optional class name for the namedtuple subclass\n used for the row data.\n* `column_names`: optional iterable of column headings; if\n provided then the file is not expected to have internal column\n headings\n* `computed`: optional keyword parameter providing a mapping\n of str to functions of `self`; these strings are available\n via __getitem__\n* `preprocess`: optional keyword parameter providing a callable\n to modify CSV rows before they are converted into the namedtuple.\n It receives a context object an the data row. It may return\n the row (possibly modified), or None to drop the row.\n* `mixin`: an optional mixin class for the generated namedtuple subclass\n to provide extra methods or properties\n\nAll other keyword paramaters are passed to csv_reader(). This\nis a very thin shim around `cs.mappings.named_column_tuples`.\n\nExamples:\n\n >>> cls, rows = csv_import(['a, b', '1,2', '3,4'], class_name='Example_AB')\n >>> cls #doctest: +ELLIPSIS\n .factory at ...>\n >>> list(rows)\n [Example_AB(a='1', b='2'), Example_AB(a='3', b='4')]\n\n >>> cls, rows = csv_import(['1,2', '3,4'], class_name='Example_DEFG', column_names=['D E', 'F G '])\n >>> list(rows)\n [Example_DEFG(d_e='1', f_g='2'), Example_DEFG(d_e='3', f_g='4')]\n\n## Function `csv_writerow(csvw, row, encoding='utf-8')`\n\nWrite the supplied row as strings encoded with the supplied `encoding`,\ndefault 'utf-8'.\n\n## Function `xl_import(workbook, sheet_name, skip_rows=0, **kw)`\n\nRead the named `sheet_name` from the Excel XLSX file named\n`filename` as for `csv_import`.\nReturns a row namedtuple factory and an iterable of instances.\n\nParameters:\n* `workbook`: Excel work book from which to load the sheet; if\n this is a str then the work book is obtained from\n openpyxl.load_workbook()\n* `sheet_name`: the name of the work book sheet whose data should be imported\n\nOther keyword parameters are as for cs.mappings.named_column_tuples.\n\nNOTE: this function requires the `openpyxl` module to be available.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/cameron_simpson/css/commits/all", "keywords": "python2,python3", "license": "", "maintainer": "", "maintainer_email": "", "name": "cs.csvutils", "package_url": "https://pypi.org/project/cs.csvutils/", "platform": "", "project_url": "https://pypi.org/project/cs.csvutils/", "project_urls": { "Homepage": "https://bitbucket.org/cameron_simpson/css/commits/all" }, "release_url": "https://pypi.org/project/cs.csvutils/20190103/", "requires_dist": null, "requires_python": "", "summary": "CSV file related facilities", "version": "20190103" }, "last_serial": 4654364, "releases": { "20150116": [ { "comment_text": "", "digests": { "md5": "e2e88c74be197038b687b597ae8543b1", "sha256": "7adae04fc96b7c5526a9830b8007bcb616db601137f9e5e093e6835b989b84cd" }, "downloads": -1, "filename": "cs.csvutils-20150116.tar.gz", "has_sig": false, "md5_digest": "e2e88c74be197038b687b597ae8543b1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2508, "upload_time": "2015-01-18T06:14:43", "url": "https://files.pythonhosted.org/packages/b7/5f/3915dd1db2690ae613fad3775662235db6111ebef17d0ca3831b54881436/cs.csvutils-20150116.tar.gz" } ], "20160828": [ { "comment_text": "", "digests": { "md5": "d88ecc1194127fda2fd4ad3a40a42216", "sha256": "7948fe9363ae83c88c7571412b0ead7f0b0906ae1d71acd9c96ebbff405bf138" }, "downloads": -1, "filename": "cs.csvutils-20160828.tar.gz", "has_sig": false, "md5_digest": "d88ecc1194127fda2fd4ad3a40a42216", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2942, "upload_time": "2016-08-28T06:04:08", "url": "https://files.pythonhosted.org/packages/fe/0a/9d7f864ba83b2c34850390cb20e6f2d661a9a190df0611372f7d7f0f25b0/cs.csvutils-20160828.tar.gz" } ], "20180720": [ { "comment_text": "", "digests": { "md5": "e35c5684a8098827c95472c82e4d7b37", "sha256": "5e2fd17665b525247246cebd498ac214420a4958e7714c9f2f7fef6a775af0d7" }, "downloads": -1, "filename": "cs.csvutils-20180720.tar.gz", "has_sig": false, "md5_digest": "e35c5684a8098827c95472c82e4d7b37", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3509, "upload_time": "2018-07-20T00:12:32", "url": "https://files.pythonhosted.org/packages/13/77/4b72e89c332b45188f8d2ea4c9c6b915ed54845ec7583302da921fb2bb52/cs.csvutils-20180720.tar.gz" } ], "20190103": [ { "comment_text": "", "digests": { "md5": "e0afc685e505594f8905fc57a91401f1", "sha256": "3df8183b81c09430c666efce798feb2b2fdfbf7cb8cd23cd3f893c3a76a6fd1e" }, "downloads": -1, "filename": "cs.csvutils-20190103.tar.gz", "has_sig": false, "md5_digest": "e0afc685e505594f8905fc57a91401f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4109, "upload_time": "2019-01-02T22:26:23", "url": "https://files.pythonhosted.org/packages/29/d9/cf6d2bac53737a86bf2a8cc0e24eeee3e446fa5b8c5182d96b82a732c7ac/cs.csvutils-20190103.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e0afc685e505594f8905fc57a91401f1", "sha256": "3df8183b81c09430c666efce798feb2b2fdfbf7cb8cd23cd3f893c3a76a6fd1e" }, "downloads": -1, "filename": "cs.csvutils-20190103.tar.gz", "has_sig": false, "md5_digest": "e0afc685e505594f8905fc57a91401f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4109, "upload_time": "2019-01-02T22:26:23", "url": "https://files.pythonhosted.org/packages/29/d9/cf6d2bac53737a86bf2a8cc0e24eeee3e446fa5b8c5182d96b82a732c7ac/cs.csvutils-20190103.tar.gz" } ] }