Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import csv
- with open('teams.json') as f:
- teams = json.load(f)
- SEDE = {
- 'Rio de Janeiro': 'RJ',
- 'Rio Grande do Sul': 'RS',
- 'Rio Grande do Norte': 'RN',
- 'Paraiba': 'PB',
- 'Distrito Federal': 'DF',
- 'Minas Gerais': 'MG',
- 'Mato Grosso do Sul': 'MS',
- 'Mato Grosso': 'MT',
- 'Parana': 'PR',
- 'Ceara': 'CE',
- 'Amapa': 'AP',
- 'Maranhao': 'MA',
- 'Sao Paulo': 'SP',
- 'Alagoas': 'AL',
- 'Santa Catarina': 'SC',
- 'Bahia': 'BA',
- 'Amazonas': 'AM',
- 'Para': 'PA',
- 'Rondonia': 'RO',
- 'Piaui': 'PI',
- 'Acre': 'AC',
- 'Pernambuco': 'PE',
- 'Sergipe': 'SE',
- 'Goias': 'GO',
- 'Roraima': 'RR',
- 'Espirito Santo': 'ES',
- }
- with open('teams.csv', 'w', newline='') as f:
- rows = sorted([((SEDE[team['site']['name']], team['institution'].strip(), team['name'].strip())) for team in teams])
- writer = csv.writer(f)
- writer.writerows(rows)
- # From the spreadsheet
- with open('planilha.csv', newline='') as f:
- rows = csv.reader(f)
- rows = sorted([(row[1], row[2], row[3]) for row in rows if len(row[1]) == 2])
- with open('planilha.csv', 'w', newline='') as f:
- writer = csv.writer(f)
- writer.writerows(rows)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement