选择性读取speedtest cli生成的文件输出
speedtest-reader的Python项目详细描述
要读取的库、缓冲区和由生成的时间片输出 speedtest-cli
最近的更改
- 完成API重新设计(请参阅下面的Python API)
安装
pip/easy_安装
pip install speedtest_reader
或
easy_install speedtest_reader
Github
pip install git+https://github.com/shuntingyard/speedtest_reader.git
或
git clone https://github.com/shuntingyard/speedtest_reader.git cd speedtest_reader python setup.py install
python api
fromspeedtest_readerimportformat_timestamps,Reader,utilsensor1=Reader("~/speedtest.csv")@util.to_Mbitdefslice_s1(**kwargs):start,end=format_timestamps(**kwargs)returnsensor1.copy_df(start,end)# Test API setupprint(slice_s1(start="2019-06-01"))print(slice_s1(start="July 1",end="July 3"))print(slice_s1(start="yesterday"))
示例部分
情节
importplotlyimportplotly.graph_objsasgofromspeedtest_readerimportformat_timestamps,Reader,utilsensor1=Reader("~/speedtest.csv")@util.append_tslocal()defslice_s1(**kwargs):start,end=format_timestamps(**kwargs)returnsensor1.copy_df(start,end)# minimal line- and scatterplot exampledf=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)
海伯恩
importmatplotlib.pyplotaspltimportseabornassnsfromspeedtest_readerimportformat_timestamps,Reader,utilsensor1=Reader("~/speedtest.csv")@util.to_Mbit@util.append_mpldate(colname="date2num")defslice_s1(**kwargs):start,end=format_timestamps(**kwargs)returnsensor1.copy_df(start,end)# minimal scatterplot examplets=slice_s1()["date2num"]dl=slice_s1()["Download"]_,ax=plt.subplots()sns.scatterplot(ts,dl)ax.xaxis_date()plt.show()
时区配置
fromspeedtest_readerimportformat_timestamps,Reader,utilsensor1=Reader("~/speedtest.csv")@util.append_tslocal(tz="EST")# zone for local timestamp to appenddefslice_EST(**kwargs):kwargs["tz"]="EST"# zone to use for slicingstart,end=format_timestamps(**kwargs)returnsensor1.copy_df(start,end)# use local timezone (selected by module 'tzlocal')@util.append_tslocal()defslice_local(**kwargs):start,end=format_timestamps(**kwargs)returnsensor1.copy_df(start,end)# test configured- and local timezone setupprint(slice_EST(start="yesterday"))print(slice_local(start="yesterday"))
更改日志
版本0.0.4
- 完成API重新设计