Created
July 10, 2019 13:09
-
-
Save ohemelaar/6e9f3470ad00a2ed2a6b33b32a3f2ce1 to your computer and use it in GitHub Desktop.
Simple histogram data generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Change this with whatever function you want for grouping | |
def grouping(line): | |
return int(line) // (24 * 3600 * 1000) | |
histo = {} | |
with open('some_file.csv', 'r') as file: | |
for line in file.readlines(): | |
key = grouping(line) | |
histo[key] = histo.get(key, 0) + 1 | |
for k, v in histo.items(): | |
print('{},{}'.format(k,v)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment