Extract log data current python

Python was extracted with current data, written to a new file, and then manually copy to Excel to calculate the average current.

path = "19-12-26-22-35-05kernel.txt"

def readfile(name):                   
    fin=open(name, 'r')
    fout = open(path + ".out.txt", 'w')
    for lines in fin.readlines():         #按行读取text中的内容
        if 'IBAT=' in str(lines): 
            #print(lines)
            index = lines.find('IBAT=')
            fout.write(lines[index + 7: index + 9] + '\n')
    
    fout.close()
    fin.close()

if __name__ == "__main__":
    readfile(path)

reference

Python to use data from multiple txt file screening _heavenmark the blog -CSDN blog
https://blog.csdn.net/heavenmark/article/details/73526921

Guess you like

Origin www.cnblogs.com/obarong/p/12121348.html