“ Dados abertos são dados que podem ser livremente usados, reutilizados e redistribuídos por qualquer pessoa - sujeitos, no máximo, à exigência de atribuição da fonte e compartilhamento pelas mesmas regras. ”-- OpenData Handbook (definição de Open Definition)
“ O nível de acessibilidade de um dado é um filtro sobre quem conseguirá utilizá-lo. ”
print("Olá, galera do IFC!")
if condicao1 and condicao2:
comando1
if condicao3 or condicao4:
comando2
comando3
elif 5 < x <= 10:
comando4
elif condicao6:
comando5
else:
comando6
arquivo_1 = open('nome.txt')
for linha in arquivo_1:
print(linha)
arquivo_1.close()
arquivo_2 = open('nome-2.txt', 'w')
arquivo_2.write('Python rules!')
arquivo_2.close()
(live coding IPython)
import csv
municipios = csv.DictReader(open('brasil.csv'))
for municipio in municipios:
if municipio['estado'] == 'PR':
densidade = int(municipio['habitantes']) / float(municipio['area'])
print(municipio['nome'] + '/PR' + ': ' + str(densidade) + ' hab/km²')
import urllib
url = 'http://pythonic.cafe/'
pagina = urllib.urlopen(url)
print(pagina.read())
import os
from splinter import Browser
os.makedirs('news-ifc', exist_ok=True)
browser = Browser('firefox')
browser.visit('http://eventos.ifc.edu.br/sepe/')
news = browser.find_by_xpath('.//div[@class="titulos"]/h2/a')
links = [(link.value, link['href']) for link in news]
print('Found {} links.'.format(len(links)))
for title, url in links:
print(' Visiting', title)
browser.visit(url)
filename = 'news-ifc/{}.html'.format(title)
with open(filename, mode='w', encoding='utf-8') as fobj:
fobj.write(browser.html)
browser.quit()
>>> import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
Investigar as questões de gênero no Brasil e América Latina, com dados abertos e técnicas de jornalismo de dados.
pip install rows # Python Package Index
apt-get install rows # Debian
dnf install rows # Fedora
import rows
table1 = rows.import_from_csv('data/brazilian-cities.csv')
for row in table1:
print(row)
Row(state='PR',
city='Curitiba',
inhabitants=1751907,
area=435.04)
(live coding no IPython)
import rows
table2 = rows.import_from_xls('data/brazilian-cities.xls')
for row in table2:
print(row)
import rows
table3 = rows.import_from_html('data/brazilian-cities.html')
for row in table3:
print(row)
github.com/generonumero/olimpiadas
(live coding - CLI)
06 a 11 de outubro de 2017
Belo Horizonte/MG
25 e 26 de novembro de 2017
São Paulo/SP