Skip to main content

Selectively read file output generated by speedtest-cli

Project description

Library to read, buffer and time-slice output generated by speedtest-cli

Latest Version Travis License

Versions

speedtest_reader works with Python 3

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

Python API

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

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

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

speedtest_reader-0.0.4.tar.gz (37.6 kB view details)

Uploaded Source

File details

Details for the file speedtest_reader-0.0.4.tar.gz.

File metadata

  • Download URL: speedtest_reader-0.0.4.tar.gz
  • Upload date:
  • Size: 37.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for speedtest_reader-0.0.4.tar.gz
Algorithm Hash digest
SHA256 7aa7da742d24ef5daa400f5ce68addcdd148b6fdf40127aac5002ee12fd226c5
MD5 5e750d4b09fdfe7f830a961ef974e686
BLAKE2b-256 7f788b8f1928c92f8f00c1649b4427eb9b2f4f3a858049943eaa797503eaec28

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page