移动平均图

Moving Average plot

我有一个巨大的文本文件,类似于下面 link 中的 table。每个 xxx 框的行数不同但列数相同:

Here is the link to figure

我无法编写适用于整个文本文件的通用 python 代码。 你能帮我解决一下吗?

我试过这段代码,但出现错误:

我相信您要查找的内容的总体布局是:

with open('file','r') as file:
    groups = [] # Will contain the final data
    current_group = [] # Temporary

    line = file.readline()
    while line != "":
        if line == "XXXX":
            # Store the current group and start a new one
            groups.append(current_group)
            current_group = []
        else:
            # Add the number to the current group
            current_group.append(int(line.split()[2]))
        line = file.readline()