[Python] How to read the data from log file and then calculate the results and plot a graph...

Discussão em 'Python' iniciado por Stack, Janeiro 18, 2025.

  1. Stack

    Stack Membro Participativo

    I have a log file looks like this:

    # seconds.nanoseconds+offset(sequence)
    1737119268.154152577+1.009023e-03(0)
    1737119268.174213704+1.055868e-03(1)
    1737119268.194189758+9.929340e-04(2)
    1737119268.214228223+1.148472e-03(3)
    1737119268.234281484+1.086814e-03(4)
    1737119268.254280558+1.110649e-03(5)
    1737119268.274280203+1.066759e-03(6)
    1737119268.294279759+1.261670e-03(7)
    1737119268.314287395+1.231778e-03(8)
    1737119268.334195574+9.443450e-04(9)
    1737119268.354297130+9.879940e-04(10)
    1737119268.374272817+1.080131e-03(11)
    1737119268.394278885+1.024396e-03(12)
    1737119268.414284465+9.852860e-04(13)
    1737119268.434281287+1.055045e-03(14)
    1737119268.454279880+1.374439e-03(15)
    1737119268.474283558+1.287552e-03(16)
    1737119268.494280915+1.188272e-03(17)
    1737119268.514209498+9.444750e-04(18)


    I want to write a python script to read the data from the log file and then calculate the results, for example: 1737119268.154152577+1.009023e-03 and split the numbers in '(0)'. Then i want this python script to plot a graph of the calculated results. So far i tried this

    log_Name = 'test_rtt_25-01-17_13-07-41_values5_rate50.log'
    log_Path = "/home/ubuntu/results-25-01-09-docker/"
    true_Path = log_Path + log_Name
    with open(true_Path, "r") as f:
    lines = f.readlines()
    data = []
    for line in lines:
    print(line)
    data.append(line.split('('))

    print(data)


    But I don't really get what i want and i also don't know how to let the script calculate and plot a graph of the the results. Pls help, Thanks a lot!

    Continue reading...

Compartilhe esta Página