Home > other >  Python text file draw multiple question
Python text file draw multiple question

Time:03-26

I have a text content, which is the result of the multiple host according to the minutes of the ping, my appeal is the result of the multiple host ping painting on the same line chart,
The results of each host ping format is as follows:
The first line is the IP, and can ping logo, can not;
The second line is the host name;
The back is the result of ping

Text content is as follows:
192.168.0.1 | success | rc=0 & gt;>
MY_HOST_001
4202-11-04 00:02
10202-11-04 00:56
10 and the 2020-11-04 00:58
40, 2020-11-04 01:00
32, 2020-11-04 01:02
In 250, the 2020-11-04 01:06
2, 2020-11-04 02:29
2, 2020-11-04 02:41
2, 2020-11-04 05:25
2, 2020-11-04 07:43
Eight, the 2020-11-04 08:06
2, 2020-11-04 09:10
2, 2020-11-04 09:11
2, 2020-11-04 1
2, and 2020-11-04
2, 2020-11-04 he
2, 2020-11-04 13:42
2, 2020-11-04 the plague
4, 2020-11-04 or

192.168.0.2 | success | rc=0 & gt;>
MY_HOST_002
2, 2020-11-04 00:29
4, 2020-11-04 00:56
Eight, the 2020-11-04 01:00
24, 2020-11-04 01:02
In 210, the 2020-11-04 01:06
4, 2020-11-04 03:22
2, 2020-11-04 04:19
4, 2020-11-04 06:14
10 and the 2020-11-04 06:52
Eight, the 2020-11-04 06:53
2, 2020-11-04 07:19
2, 2020-11-04 09:09
2, 2020-11-04 and
2, the 2020-11-04 12:17
6, 2020-11-04 13:02
6, 2020-11-04 for

Now a host of ping result picture script is as follows:
The import matplotlib. Pyplot as PLT

Ping. TXT file=open (' ') # open the document
Data=# https://bbs.csdn.net/topics/file.readlines () reads the document data
Para_1=[] # new list, used to hold the first column data
Para_2=[] # new list, used to hold the second column data

For num in data:
# the split for every line of figures comma separated into multiple objects
# take divided after the second column to add to the list of para_1
Para_1. Append (num. Split (', ') [1])
# 0 after segmentation, converted to float format after add to the list of para_1
Para_2. Append (float (num. Split (', ') [0]))
PLT. Figure ()
PLT. Title (' ping ')
PLT. The plot (para_1 para_2)
PLT. The show ()

Can you tell me how to modify the script? Please advice, thanks!
  • Related