I need to plot a histogram in python based on some data in a notepad file. My notepad file contains 10000 lines, in each line I have ten hypothesis numbers from 0 to 255:
....
....
[205 246 19 68 118 44 45 72 210 162]
[205 246 19 68 118 44 45 72 210 162]
[205 246 19 68 118 44 45 72 210 162]
[205 246 19 68 118 44 72 45 210 162]
[205 246 19 68 118 44 45 72 210 162]
[246 205 19 68 118 44 72 45 210 162]
[205 246 19 68 118 44 72 45 210 162]
[205 246 19 68 118 44 72 45 210 162]
[205 246 19 68 118 44 72 45 210 162]
[205 246 19 68 118 44 72 45 210 162]
[205 246 19 68 118 44 72 45 210 162]
[205 246 19 68 118 44 72 45 210 162]
[205 246 19 68 118 44 72 45 210 162]
[205 246 19 68 118 44 72 45 210 162]
[205 246 19 118 44 68 72 45 210 162]
[205 246 19 118 68 44 72 45 210 162]
[205 246 19 118 68 44 72 45 210 162]
[205 246 19 118 68 44 72 45 210 162]
[205 246 19 118 68 44 72 45 210 162]
So my goal is to take the last line, then check how many times each number is repeated in all the notepad file.
For example, this is my last line [205 246 19 118 68 44 72 45 210 162]
. I need to plot my histogram based on the number of repetition of each number in all the file.
I need than to extract its rank:
import matplotlib.pyplot as plt
import numpy as np
fileHandle = open('path_File',"rb" )
lineList = fileHandle.readlines()
fileHandle.close()
print (lineList)
print ("The last line is:")
print (lineList[-1])
I extract from this code the last line, but I can't compute the repetition of each number in all the file, how to plot the histogram based on that?