Skip to content

Instantly share code, notes, and snippets.

@yagotome
Created September 11, 2019 05:00
Show Gist options
  • Save yagotome/2ce1f8f8bb849d588bcb4b0b56064c21 to your computer and use it in GitHub Desktop.
Save yagotome/2ce1f8f8bb849d588bcb4b0b56064c21 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