Advertisement
rex9840

csv_

May 10th, 2021
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.07 KB | None | 0 0
  1. import requests
  2. import csv
  3. import pandas as pd
  4. from typing import *
  5.  
  6. file = requests.get("http://ka-mao.xyz/log/rtime")
  7. content = file.text
  8. avg_resp_time = 0
  9. entry = 0
  10. data=dict()
  11. date=list()
  12. time=list()
  13. request=list()
  14. timetaken=list()
  15. path=list()
  16. lines = content.split("\n")
  17. for line in lines:
  18.         try:
  19.             sep=line.split(' ')
  20.            
  21.             # print(sep[0])
  22.             # print(sep[1])
  23.             # print(sep[4])
  24.             # print(sep[5])
  25.             # print(sep[-2])
  26.            
  27.  
  28.             date.append(sep[0].replace(',',''))
  29.             time.append(sep[1])
  30.             request.append(sep[4])
  31.             path.append(sep[5])
  32.            
  33.            
  34.             timetaken.append(float(line.split(' ')[-2].replace('ms',"")))
  35.         except IndexError:
  36.             continue
  37.        
  38.        
  39.        
  40. data={'date':date,"time":time ,'reequest ':request ,"path ":path ,"timetaken":timetaken}
  41. df = pd.DataFrame.from_dict(data=data,orient='index')
  42. df=df.transpose()
  43.  
  44. df.to_csv('./timeout.csv')      
  45.  
  46.  
  47. print(df.describe())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement