speedtest-reader 0.0.4
Selectively read file output generated by speedtest-cli
License: mit
Requires Python: >=3.*

speedtest_reader
================

Library to read, buffer and time-slice output generated by
`speedtest-cli <https://github.com/sivel/speedtest-cli>`_

.. image:: https://img.shields.io/pypi/v/speedtest-reader.svg
        :target: https://pypi.org/project/speedtest-reader/
        :alt: Latest Version
.. image:: https://img.shields.io/travis/shuntingyard/speedtest-reader.svg
        :target: https://travis-ci.com/shuntingyard/speedtest_reader/
        :alt: Travis
.. image:: https://img.shields.io/pypi/l/speedtest-reader.svg
        :target: https://github.com/shuntingyard/speedtest_reader/blob/master/LICENSE.txt
        :alt: License

Versions
--------

speedtest_reader works with Python 3

.. image:: https://img.shields.io/pypi/pyversions/speedtest-reader.svg
        :target: https://pypi.org/project/speedtest-reader/
        :alt: Versions

Recent changes
--------------

- Complete API redesign (see Python API below)

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

pip / easy\_install
~~~~~~~~~~~~~~~~~~~

::

    pip install speedtest_reader

or

::

    easy_install speedtest_reader

Github
~~~~~~

::

    pip install git+https://github.com/shuntingyard/speedtest_reader.git

or

::

    git clone https://github.com/shuntingyard/speedtest_reader.git
    cd speedtest_reader
    python setup.py install

.. _API:

Python API
----------

.. code:: python

   from speedtest_reader import format_timestamps, Reader, util

   sensor1 = Reader("~/speedtest.csv")


   @util.to_Mbit
   def slice_s1(**kwargs):
       start, end = format_timestamps(**kwargs)
       return sensor1.copy_df(start, end)


   # Test API setup
   print(slice_s1(start="2019-06-01"))
   print(slice_s1(start="July 1", end="July 3"))
   print(slice_s1(start="yesterday"))

Example section
---------------

plotly
~~~~~~

.. code:: python

   import plotly
   import plotly.graph_objs as go
   from speedtest_reader import format_timestamps, Reader, util

   sensor1 = Reader("~/speedtest.csv")


   @util.append_tslocal()
   def slice_s1(**kwargs):
       start, end = format_timestamps(**kwargs)
       return sensor1.copy_df(start, end)


   # minimal line- and scatterplot example
   df = slice_s1()
   graph = dict(
       data=[
           go.Scatter(
               x=df["tslocal"], y=df["Download"], mode="lines", connectgaps=False
           ),
           go.Scatter(x=df["tslocal"], y=df["Upload"], mode="markers"),
       ]
   )
   plotly.offline.plot(graph)

seaborn
~~~~~~~

.. code:: python

   import matplotlib.pyplot as plt
   import seaborn as sns
   from speedtest_reader import format_timestamps, Reader, util

   sensor1 = Reader("~/speedtest.csv")


   @util.to_Mbit
   @util.append_mpldate(colname="date2num")
   def slice_s1(**kwargs):
       start, end = format_timestamps(**kwargs)
       return sensor1.copy_df(start, end)


   # minimal scatterplot example
   ts = slice_s1()["date2num"]
   dl = slice_s1()["Download"]
   _, ax = plt.subplots()
   sns.scatterplot(ts, dl)
   ax.xaxis_date()
   plt.show()

timezone config
~~~~~~~~~~~~~~~

.. code:: python

   from speedtest_reader import format_timestamps, Reader, util

   sensor1 = Reader("~/speedtest.csv")


   @util.append_tslocal(tz="EST")  # zone for local timestamp to append
   def slice_EST(**kwargs):
       kwargs["tz"] = "EST"  # zone to use for slicing
       start, end = format_timestamps(**kwargs)
       return sensor1.copy_df(start, end)


   # use local timezone (selected by module 'tzlocal')
   @util.append_tslocal()
   def slice_local(**kwargs):
       start, end = format_timestamps(**kwargs)
       return sensor1.copy_df(start, end)


   # test configured- and local timezone setup
   print(slice_EST(start="yesterday"))
   print(slice_local(start="yesterday"))

Changelog
---------

Version 0.0.4
~~~~~~~~~~~~~

- Complete API redesign