{ "info": { "author": "Diogo Munaro Vieira, Isvaldo Fernandes de Souza, Thiago Pereira Fernandes", "author_email": "diogo.mvieira@gmail.com, isvaldo.fernandes@gmail.com, thiago.fernandes210@gmail.com", "bugtrack_url": null, "classifiers": [ "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Database", "Topic :: Office/Business", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "PyHeaderFile\n************\n\nThe PyHeaderFile helps the work with files that have extensions csv, xls and xlsx.\n\nThis project aims **reading files over the header (column names)**. With this module we can handle **Csv, Xls and Xlsx files using same interface**. Thus, we can convert extensions, strip values in lines, change cell style of Excel files, read a specific Excel file, read an specific cell and read just some headers.\n\nInstall\n=======\n\n::\n\n pip install pyheaderfile\n\nHow to use\n==========\n\nFirst of all you need to import module:\n\n::\n\n from pyheaderfile import Csv, Xls, Xlsx, guess_type\n\nEach of them will be explained below.\n\n\nClass csv\n---------\n\nRead csv\n^^^^^^^^\n\nDefault encode is utf8, but you can change it. Default strip is false, but classes can strip each value automatically:\n\n::\n\n file = Csv(name=\u2019file.csv\u2019, encode='latin1', strip=True)\n for row in file.read():\n print row \n\n\nSet Header\n^^^^^^^^^^\n\n::\n\n file.header = ['col1', 'col2','col3']\n\n\nCreate csv\n^^^^^^^^^^\n\n::\n\n file = Csv(name='filename.csv', header=['col1','col2','col3'])\n\n\nWrite list csv\n^^^^^^^^^^^^^^\n\n::\n\n file.write(['col1','col2','col3'])\n\n\nWrite dict csv\n^^^^^^^^^^^^^^\n\n::\n\n file.write(dict(header=value))\n\nSave file\n^^^^^^^^^\n\n::\n\n file.save()\n\nClass Xls\n---------\n\nRead xls\n^^^^^^^^\n\nYou can strip automatically values from xls files too, but default value is False:\n\n::\n\n file = Xls(name=\u2019file.xls\u2019, strip=True)\n for row in file.read():\n print row \n\n\nSet Header\n^^^^^^^^^^\n\n::\n\n file.header = ['col1', 'col2','col3']\n\n\nCreate xls\n^^^^^^^^^^\n\n::\n\n file = Xls(name='filename.xls', header=['col1','col2','col3'])\n\n\nWrite list\n^^^^^^^^^^\n\n::\n\n file.write(['col1','col2','col3'])\n\n\nWrite dict\n^^^^^^^^^^\n\n::\n\n file.write(dict(header=value))\n\nSave file\n^^^^^^^^^\n\nFinally you can save the file\n\n::\n\n file.save()\n\nClass Xlsx\n----------\n\nRead\n^^^^\n\nYou can strip values from xlsx files too:\n\n::\n\n file = Xlsx(name=\u2019file.xlsx\u2019, strip=True)\n for row in file.read():\n print row \n\n\nSet Header\n^^^^^^^^^^\n\n::\n\n file.header = ['col1', 'col2','col3']\n\n\nCreate file\n^^^^^^^^^^^\n\n::\n\n file = Xlsx(name='filename.xlsx', header=['col1','col2','col3'])\n\n\nWrite list\n^^^^^^^^^^\n\n::\n\n file.write(['col_val1','col_val2','col_val3'])\n\n\nWrite dict\n^^^^^^^^^^\n\n::\n\n file.write(dict(header=value))\n\n\nSave file\n^^^^^^^^^\n\nYou can save the file to another path too\n\n::\n\n file.save('/path/to/new/file/')\n\nAlternativelly to save you can use close() that just use same path mandatorily.\n\n::\n\n file.close()\n\nWorking with memory\n-------------------\n\nWriting\n^^^^^^^\n\nObjects can be stored in memory and then saved into disk or simple stay in memory:\n\n::\n\n from StringIO import StringIO\n mem_obj = StringIO()\n xls = Xls(mem_obj, header=['first', 'second'])\n xls.write('1 guy', '2 guys')\n xls.save() # or you can xls.save('/path/to/file/')\n\nWhen you save file you retrieve StringIO contents or save its to disk specifying a directory. The content will be saved with name 'default.xls' in this case.\n\n\nReading\n^^^^^^^\n\nSame as writing you can read objects from memory. So, after you save your content you can read it again:\n\n::\n\n from StringIO import StringIO\n mem_obj = StringIO()\n xls = Xls(mem_obj, header=['first', 'second'])\n xls.write('1 guy', '2 guys')\n xls.save()\n # here use new object\n new_xls = Xls(mem_obj)\n for row in new_xls:\n print row # should echo {'first': '1 guy', 'second': '2 guys'} then next rows\n\nTricks\n------\n\nModifying extensions, name and header\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nYou can change filename and header using this:\n\n::\n\n q = Xls()\n x = Xlsx(name='filename.xlsx')\n x.name = 'ugly file name'\n x.header = ['col1', 'col2','col3']\n q(x)\n\nBE CAREFUL! You can't change name using StringIO or others memory storage. You will get an error.\n\nGuess file type\n^^^^^^^^^^^^^^^\n\nTo guess what class you need to open just use:\n\n::\n\n filename = 'test.xls'\n my_file = guess_type(filename)\n\nIf you are working with Csv or Xls, you can pass all possible kwargs and guess_type guess right kwargs:\n\n::\n\n my_file = guess_type(filename, encode='latin1', strip=True)\n\nOnly if filename is a Csv file, then guess_type send encode kwarg to instance.\n\nAnd for a SUPERCOMBO you can guess and convert everything!\n\n::\n\n my_file = guess_type(filename, **kwargs)\n convert_to = Xls()\n my_file.name = 'beautiful_name'\n my_file.header = ['col1', 'col2','col3']\n convert_to(my_file) # now your file is a xls file ;)\n convert_to.save('/my/other/path/')", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/kappius/pyheaderfile/archive/0.4.0.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/kappius/pyheaderfile", "keywords": "xls,excel,spreadsheet,workbook,xlsx,csv,txt", "license": "Apache", "maintainer": null, "maintainer_email": null, "name": "pyheaderfile", "package_url": "https://pypi.org/project/pyheaderfile/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pyheaderfile/", "project_urls": { "Download": "https://github.com/kappius/pyheaderfile/archive/0.4.0.tar.gz", "Homepage": "https://github.com/kappius/pyheaderfile" }, "release_url": "https://pypi.org/project/pyheaderfile/0.4.0/", "requires_dist": null, "requires_python": null, "summary": "Enable handle of csv, xls and xlsx files getting column header", "version": "0.4.0" }, "last_serial": 2406828, "releases": { "0.1.8": [ { "comment_text": "", "digests": { "md5": "b283903497b8a595dd4a03008129693b", "sha256": "339ab3a6d2827b4498eea59ac5d2f3004788e77a1f93057aaaf349da2dface55" }, "downloads": -1, "filename": "pyheaderfile-0.1.8.tar.gz", "has_sig": false, "md5_digest": "b283903497b8a595dd4a03008129693b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5490, "upload_time": "2014-10-28T22:24:27", "url": "https://files.pythonhosted.org/packages/cf/fd/224a182977c1738211d043a18a4c1ede0c4e23b88fd53df61619964f98c2/pyheaderfile-0.1.8.tar.gz" } ], "0.1.9": [ { "comment_text": "", "digests": { "md5": "2d41c14d45b837f628fa561bea1167cb", "sha256": "1e4c00949ef0d22bac2f74e9f54daa1d2dbe515552146813930c6b550962d6f2" }, "downloads": -1, "filename": "pyheaderfile-0.1.9.tar.gz", "has_sig": false, "md5_digest": "2d41c14d45b837f628fa561bea1167cb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5776, "upload_time": "2014-10-29T14:38:20", "url": "https://files.pythonhosted.org/packages/11/60/7ae32a12108d84fc7bee97c6a9a0e63453110ed612da9b044c842b5fb428/pyheaderfile-0.1.9.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "c054a6497f4cd3ec6c89855670bc3ebf", "sha256": "342ff3b83851b070db27282430b1c32542fa49059af516d2c010d024d4978a47" }, "downloads": -1, "filename": "pyheaderfile-0.2.0.tar.gz", "has_sig": false, "md5_digest": "c054a6497f4cd3ec6c89855670bc3ebf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6026, "upload_time": "2014-12-26T18:34:47", "url": "https://files.pythonhosted.org/packages/9b/04/4289f5637346cbc3526fb5775c64e4de3c51426d44c15a3692f3a01e7bc6/pyheaderfile-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "100ef1b018858341bdc4c1584ec1ab24", "sha256": "056005cb9b1db3ff8780d4ca738ee70ebbf71404d070333081eb39407e60d9a6" }, "downloads": -1, "filename": "pyheaderfile-0.2.1.tar.gz", "has_sig": false, "md5_digest": "100ef1b018858341bdc4c1584ec1ab24", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6251, "upload_time": "2014-12-26T18:58:20", "url": "https://files.pythonhosted.org/packages/ff/ca/7d4bef00c5db0a449bd40c4fe4c5bb4c8f138bae8b2f9ff9cdedc1e44a45/pyheaderfile-0.2.1.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "5faf14ace97c880a1783782bbd0b6d38", "sha256": "8605dca28944900dd05febe79831e1e9b86411aeb8630cfa018a0c0db2463676" }, "downloads": -1, "filename": "pyheaderfile-0.2.3.tar.gz", "has_sig": false, "md5_digest": "5faf14ace97c880a1783782bbd0b6d38", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6588, "upload_time": "2014-12-29T14:30:16", "url": "https://files.pythonhosted.org/packages/5e/9f/dfd730c8e5491ef9ad88055157ac3aa709c9e414f2391b275ba9a34ba2c9/pyheaderfile-0.2.3.tar.gz" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "e4626c383b8fefaaf343b7bfa86af15a", "sha256": "b582c1faf36dc9d4c54c8e2b39ecc3da9acffce7a0372e12558d7381c5d84089" }, "downloads": -1, "filename": "pyheaderfile-0.2.4.tar.gz", "has_sig": false, "md5_digest": "e4626c383b8fefaaf343b7bfa86af15a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7396, "upload_time": "2014-12-29T18:47:09", "url": "https://files.pythonhosted.org/packages/e1/a1/9883681846a0a5269e75677856311cb35158d1f37542ee22748642ff27a8/pyheaderfile-0.2.4.tar.gz" } ], "0.2.5": [ { "comment_text": "", "digests": { "md5": "90502e414cb6a5c07a4e8581c6faf6fe", "sha256": "8f81e0eea639d56bbe7aa0272f3f9b812d927081d24d1ab11049e34d8a954981" }, "downloads": -1, "filename": "pyheaderfile-0.2.5.tar.gz", "has_sig": false, "md5_digest": "90502e414cb6a5c07a4e8581c6faf6fe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7596, "upload_time": "2015-01-07T21:35:21", "url": "https://files.pythonhosted.org/packages/79/bf/75f74d2a6230ef0c444df3e5b25cfff9ebe33092a3a450650241ef43661c/pyheaderfile-0.2.5.tar.gz" } ], "0.2.6": [ { "comment_text": "", "digests": { "md5": "bdc4e5d6ee2f81040995c81d9c3825ad", "sha256": "6266f128da8b6ac47012b0fc1351f97f8883f0d1546324e210082ceeb0f9f6c8" }, "downloads": -1, "filename": "pyheaderfile-0.2.6.tar.gz", "has_sig": false, "md5_digest": "bdc4e5d6ee2f81040995c81d9c3825ad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7605, "upload_time": "2015-01-15T23:39:31", "url": "https://files.pythonhosted.org/packages/11/66/c083864a0a40f29b8477c9737987a6481c7f03d54691be068bd72bb96bf6/pyheaderfile-0.2.6.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "d1c55f843ffe889d5a5d92ce1b20ec9b", "sha256": "22a25fe6691cc96525f5cf0f6e1efe6f2ef34af87b9a56b4bd172a73d002e752" }, "downloads": -1, "filename": "pyheaderfile-0.3.0.tar.gz", "has_sig": false, "md5_digest": "d1c55f843ffe889d5a5d92ce1b20ec9b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3567, "upload_time": "2015-07-17T10:45:33", "url": "https://files.pythonhosted.org/packages/99/14/ef3b5ea6bf905b38b8dad45f90bd787c3cb9a2d6477225cfe76f5dbc9c36/pyheaderfile-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "d0c1554b31d9382e00cea1027db2d324", "sha256": "c8195901396aa4ecb02e722c68dca612acdd8c141f4337f93d47548c3adbb9f0" }, "downloads": -1, "filename": "pyheaderfile-0.3.1.tar.gz", "has_sig": false, "md5_digest": "d0c1554b31d9382e00cea1027db2d324", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8538, "upload_time": "2016-10-15T04:48:24", "url": "https://files.pythonhosted.org/packages/ec/01/a7e2755d508d965f07d46db9ba769762dfeb956969c33220d9446ea32104/pyheaderfile-0.3.1.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "af46a4566c1f79647cfc355d63dbd7b3", "sha256": "17e1c2c8eca1b9457e066fc45b9e649010a6a04cf48dca60b58d41919d582ea3" }, "downloads": -1, "filename": "pyheaderfile-0.4.0.tar.gz", "has_sig": false, "md5_digest": "af46a4566c1f79647cfc355d63dbd7b3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10034, "upload_time": "2016-10-18T14:07:02", "url": "https://files.pythonhosted.org/packages/14/fb/6d3b0b8f5fa038e298778b377408805a67c6750f00915cfbcc33f281c6a1/pyheaderfile-0.4.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "af46a4566c1f79647cfc355d63dbd7b3", "sha256": "17e1c2c8eca1b9457e066fc45b9e649010a6a04cf48dca60b58d41919d582ea3" }, "downloads": -1, "filename": "pyheaderfile-0.4.0.tar.gz", "has_sig": false, "md5_digest": "af46a4566c1f79647cfc355d63dbd7b3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10034, "upload_time": "2016-10-18T14:07:02", "url": "https://files.pythonhosted.org/packages/14/fb/6d3b0b8f5fa038e298778b377408805a67c6750f00915cfbcc33f281c6a1/pyheaderfile-0.4.0.tar.gz" } ] }