Selectively read file output generated by speedtest-cli
Project description
Library to read, buffer and time-slice output generated by speedtest-cli
Versions
speedtest_reader works with Python 3
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 hashes)