Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import csv
- import pandas as pd
- data=dict()
- date=list()
- time=list()
- request=list()
- timetaken=list()
- path=list()
- def web_request() -> str:
- file = requests.get("http://ka-mao.xyz/log/rtime")
- return file.text
- def dataframe_dict() -> None :
- lines=web_request().split("\n")
- for line in lines[:-1]:
- sep=line.split(' ')
- # print(sep[0])
- # print(sep[1])
- # print(sep[4])
- # print(sep[5])
- # print(sep[-2])
- date.append(sep[0].replace(',',''))
- time.append(sep[1])
- request.append(sep[4])
- path.append(sep[5])
- timetaken.append(float(line.split(' ')[-2].replace('ms',"")))
- dataframe_dict()
- def dataframe() -> None :
- data={'date':date,"time":time ,'request ':request ,"path ":path ,"timetaken":timetaken}
- print('size of the columns :',end='\n')
- print('date:',len(date),'time:',len(time),'request:',len(request),'path:',len(path),'timetaken:',len(timetaken))
- df = pd.DataFrame.from_dict(data=data,orient='columns')
- # df=df.transpose()
- df.to_csv('./timeout.csv')
- max:int
- min:int
- for x in range(len(df['timetaken'])):
- if df['timetaken'].max()==df['timetaken'][x]:
- max=x
- if df['timetaken'].min()==df['timetaken'][x]:
- min =x
- print ('--'*50)
- print('MAX:')
- print()
- print(df.iloc[max])
- print("--"*50)
- print('MIN:')
- print()
- print(df.iloc[min])
- dataframe()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement