Happy Holidays! The first stable release of get-reader, version 1.0.0 is now available.
* https://pypi.org/project/get-reader/ * https://github.com/shawnbrown/get_reader This module provides a `get_reader()` function that returns reader objects similar to those returned by `csv.reader()`. This package: * reduces common boilerplate code for handling files and reading records * reads data from CSV, pandas, SQL connections, MS Excel, DBF, and squint * provides a single interface across Python versions (including seamless Unicode-aware CSV support for Python 2) * is easy to incorporate into your own projects: * has no hard dependencies * runs on Python 2.6, 2.7, 3.2 through 3.8, PyPy, PyPy3, and Jython * is freely available under the Apache License, version 2 * can be easily vendored directly into your codebase if you don't want to include it as a dependency Some examples: >>> from get_reader import get_reader >>> >>> # CSV file. >>> reader = get_reader('myfile.csv') >>> >>> # Database connection. >>> connection = ... >>> reader = get_reader(connection, 'SELECT col1, col2 FROM mytable;') >>> >>> # Pandas DataFrame. >>> df = pd.DataFrame([...]) >>> reader = get_reader(df) >>> >>> # Excel file. >>> reader = get_reader('myfile.xlsx', worksheet='Sheet2') The internal file object is automatically closed when the iterator is exhausted, when the object is deleted, or when it is explicitly closed. An example using a context manager: >>> with get_reader('myfile.csv') as reader: >>> for row in reader: >>> print(', '.join(row)) The internal file object is also closed when exiting a with block even if the for-loop doesn't finish exhausting the reader. Install: The get-reader module has no hard dependencies; is tested on Python 2.6, 2.7, 3.2 through 3.8, PyPy, PyPy3, and Jython; and is freely available under the Apache License, version 2. You can install get_reader using pip: pip install get-reader To install optional support for MS Excel and DBF files (dBase, Foxpro, etc.), use the following: pip install get-reader[excel,dbf] Python 2 Support Statement: While official support for Python 2 ends on January 1, 2020, this project will continue to support older versions as long as the existing ecosystem provides the ability to run automated tests on those older versions. -- Python-announce-list mailing list -- python-announce-list@python.org To unsubscribe send an email to python-announce-list-le...@python.org https://mail.python.org/mailman3/lists/python-announce-list.python.org/ Support the Python Software Foundation: http://www.python.org/psf/donations/