<commit_before>==========
akagi
==========

.. image:: https://img.shields.io/pypi/v/akagi.svg
  :target: https://pypi.python.org/pypi/akagi

.. image:: https://img.shields.io/travis/ayemos/akagi.svg
  :target: https://travis-ci.org/ayemos/akagi

.. image:: https://readthedocs.org/projects/akagi/badge/?version=latest
  :target: https://akagi.readthedocs.io/en/latest/?badge=latest

.. image:: https://pyup.io/repos/github/ayemos/akagi/shield.svg
  :target: https://pyup.io/repos/github/ayemos/akagi/

.. image:: https://codeclimate.com/github/ayemos/akagi/badges/coverage.svg
  :target: https://codeclimate.com/github/ayemos/akagi/coverage

###########
akagi
###########

* Free software: MIT license

---------
Features
---------

akagi supports *iter* and *save* interface for various data sources such as Amazon Redshift, Amazon S3 (more in future).

-------------
Installation
-------------

Install via pip::

  pip install akagi

or from source::

  $ git clone https://github.com/ayemos/akagi akagi
  $ cd akagi
  $ python setup.py install

--------
Example
--------

++++++++++++++++++
MySQLDataSource
++++++++++++++++++

.. code:: python

  with MySQLDataSource.for_query(
          'select * from (select user_id, path from logs.imp limit 10000)', # Your Query here
          ) as ds:
      ds.save('./akagi_test') # save results to local

      for d in ds:
          print(d) # iterate on result

++++++++++++++++++
RedshiftDataSource
++++++++++++++++++

.. code:: python

  with RedshiftDataSource.for_query(
          'select * from (select user_id, path from logs.imp limit 10000)', # Your Query here
          'logs', # schema
          'imp', # table (Those two are used to generate unique prefix for S3 object (e.g. logs/imp/20170312_081527)
          'log-redshift-unload.ap-northeast-1', # S3 Bucket for intermediate storage
          ) as ds:
      ds.save('./akagi_test') # save results to local

      for d in ds:
          print(d) # iterate on result

++++++++++++
S3DataSource
++++++++++++


.. code:: python

  with S3DataSource.for_prefix(
          'image-data.ap-northeast-1',
          'data/image_net/zebra',
          FileFormat.BINARY) as ds:
      ...

++++++++++++++++++
LocalDataSource
++++++++++++++++++

.. code:: python

  with LocalDataSource.for_path(
        './PATH/TO/YOUR/DATA/DIR',
        'csv') as ds:
      ds.save('./akagi_test') # save results to local

      for d in ds:
          print(d) # iterate on result

--------<commit_msg>Update README.rst<commit_after>==========
akagi
==========

.. image:: https://img.shields.io/pypi/v/akagi.svg
  :target: https://pypi.python.org/pypi/akagi

.. image:: https://img.shields.io/travis/ayemos/akagi.svg
  :target: https://travis-ci.org/ayemos/akagi

.. image:: https://readthedocs.org/projects/akagi/badge/?version=latest
  :target: https://akagi.readthedocs.io/en/latest/?badge=latest

.. image:: https://pyup.io/repos/github/ayemos/akagi/shield.svg
  :target: https://pyup.io/repos/github/ayemos/akagi/

.. image:: https://codeclimate.com/github/ayemos/akagi/badges/coverage.svg
  :target: https://codeclimate.com/github/ayemos/akagi/coverage

###########
akagi
###########

* Free software: MIT license

---------
Features
---------

akagi supports *iter* and *save* interface for various data sources such as Amazon Redshift, Amazon S3 (more in future).

-------------
Installation
-------------

Install via pip::

  pip install akagi

or from source::

  $ git clone https://github.com/ayemos/akagi akagi
  $ cd akagi
  $ python setup.py install

--------
Example
--------

++++++++++++++++++
MySQLDataSource
++++++++++++++++++

.. code:: python

  from akagi.data_sources import MySQLDataSource

  with MySQLDataSource.for_query(
          'select * from (select user_id, path from logs.imp limit 10000)', # Your Query here
          ) as ds:
      ds.save('./akagi_test') # save results to local

      for d in ds:
          print(d) # iterate on result

++++++++++++++++++
RedshiftDataSource
++++++++++++++++++

.. code:: python

  from akagi.data_sources import RedshiftDataSource

  with RedshiftDataSource.for_query(
          'select * from (select user_id, path from logs.imp limit 10000)', # Your Query here
          'logs', # schema
          'imp', # table (Those two are used to generate unique prefix for S3 object (e.g. logs/imp/20170312_081527)
          'log-redshift-unload.ap-northeast-1', # S3 Bucket for intermediate storage
          ) as ds:
      ds.save('./akagi_test') # save results to local

      for d in ds:
          print(d) # iterate on result

++++++++++++
S3DataSource
++++++++++++


.. code:: python

  from akagi.data_sources import S3DataSource

  with S3DataSource.for_prefix(
          'image-data.ap-northeast-1',
          'data/image_net/zebra',
          FileFormat.BINARY) as ds:
      ...

++++++++++++++++++
LocalDataSource
++++++++++++++++++

.. code:: python

  from akagi.data_sources import LocalDataSource

  with LocalDataSource.for_path(
        './PATH/TO/YOUR/DATA/DIR',
        'csv') as ds:
      ds.save('./akagi_test') # save results to local

      for d in ds:
          print(d) # iterate on result

--------
{'fraction_non_alphanumeric': 0.20366795366795368, 'fraction_numerical': 0.012162162162162163, 'mean_word_length': 2.6823027718550105, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 22, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1583463', 'n_tokens_mistral': 1745, 'n_tokens_neox': 1618, 'n_words': 389}