Skip to content

Instantly share code, notes, and snippets.

@bernardolm
Forked from yagotome/github-digest.py
Created September 16, 2019 23:14
Show Gist options
  • Save bernardolm/35c3c4b08d854bb07d076558e8e2b8a9 to your computer and use it in GitHub Desktop.
Save bernardolm/35c3c4b08d854bb07d076558e8e2b8a9 to your computer and use it in GitHub Desktop.
Resumo do arquivo de logs do github, rode esse script com python3 e com o pandas instalado (pip install pandas)
import sys
import pandas as pd
def parse_line(line):
return list(map(lambda l: l.strip(), line.split('|')))
with open(sys.argv[1], 'r', encoding='utf8') as f:
lines = f.readlines()
[header, _, *rows] = lines
df = pd.DataFrame([parse_line(row) for row in rows])
df.columns = parse_line(header)
print('Países')
print(df['country_code'].value_counts())
print()
print('Cidades')
print(df['city'].value_counts())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment