Skip to content

Instantly share code, notes, and snippets.

@ohemelaar
Created July 10, 2019 13:09
Show Gist options
  • Save ohemelaar/6e9f3470ad00a2ed2a6b33b32a3f2ce1 to your computer and use it in GitHub Desktop.
Save ohemelaar/6e9f3470ad00a2ed2a6b33b32a3f2ce1 to your computer and use it in GitHub Desktop.
Simple histogram data generator
#!/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