Reputation: 2680
i want to make a histogram spanning multiple files in a Folder. Example:
File 1:
Alpha
Beta
Ceta
Delta
File 2:
Delta
Ceta
Alpha
File 3:
Beta
Delta
I know that i can create a histogram using Numpy with:
axHistx = plt.axes(range)
How can i use this to create a histogram over multiple files, that gives me the absolute number of Occurrences of the Strings?
Upvotes: 0
Views: 246
Reputation: 19169
If you are just trying to count the numbers of instances across all files, you could do this:
counts = {}
for f in filenames:
for val in [s.strip() for s in open(f).readlines()]:
counts[val] = counts.get(val, 0) + 1
Upvotes: 2