Skip to content

Instantly share code, notes, and snippets.

View abevieiramota's full-sized avatar
🎯
Focusing

Abelardo Vieira Mota abevieiramota

🎯
Focusing
View GitHub Profile
@abevieiramota
abevieiramota / gist:6a6beca86635f756d9ef8dd6fc14471f
Created February 14, 2019 11:35
retorna a coluna com maior valor
with tabela as (
select format('%s.%s', quote_ident(nsp.nspname), quote_ident(t.tablename)) as tablename, c.oid
from pg_catalog.pg_tables t
inner join pg_catalog.pg_class c on c.relname = t.tablename
inner join pg_catalog.pg_namespace nsp on nsp.nspname = t.schemaname and nsp.oid = c.relnamespace
where t.tablename = :tablename and nsp.nspname = :schemaname
), cols_dif_resultado as (
select
t.tablename, att.attname as col
from pg_catalog.pg_attribute att
with tabela as (
select format('%s.%s', quote_ident(nsp.nspname), quote_ident(t.tablename)) as tablename, c.oid
from pg_catalog.pg_tables t
inner join pg_catalog.pg_class c on c.relname = t.tablename
inner join pg_catalog.pg_namespace nsp on nsp.nspname = t.schemaname and nsp.oid = c.relnamespace
where t.tablename = :tablename and nsp.nspname = :schemaname
), cases1 as (
select
format('when i = %s and a.%s <> b.%s then ''%s''', row_number() over() - 1, quote_ident(att.attname), quote_ident(att.attname), quote_ident(att.attname)) as case1,
format('when i = %s and a.%s <> b.%s then a.%s::text', row_number() over() - 1, quote_ident(att.attname), quote_ident(att.attname), quote_ident(att.attname)) as case2,
-- salva statistics de uso de tabelas
create temporary table "Abelardo Vieira Mota" as
select * from pg_catalog.pg_stat_user_tables;
-- SQL qualquer
-- verifica que mudanças houve
select
n.schemaname, n.relname,
t.seq_scan - n.seq_scan as seq_scan,
import pandas as pd
from io import StringIO
s = """
hora_ini,hora_fim
2018-07-01 00:01:00,2018-07-01 00:03:00
2018-07-01 00:00:00,2018-07-01 00:04:00
2018-07-01 00:00:00,2018-07-01 00:01:00
2018-07-01 00:00:01,2018-07-01 00:01:00
"""
tempo = int(input('Diz a velocidade aí: '))
espaco = int(input('Dis o espaço aí: '))
velocidade = espaco / tempo
print('A velocidade é ', velocidade)
s = """
users artist gender plays age
0 a aesop rock m 72 28.0
1 b air m 178 28.0
2 c amon tobin m 106 28.0
3 d animal collective m 203 28.0
4 e annie m 75 28.0
"""
import io
import os
import xml.etree.ElementTree as ET
import pandas as pd
tree = ET.parse('../data/webnlg2017/challenge_data_train_dev/train/2triples/2triples_Airport_train_challenge.xml')
root = tree.getroot()
all_elem = list(root.iter('entry'))
# entries
import re
import datetime
import codecs
c = re.compile('\d{1,4}-\d{1,2}-\d{1,2}')
with codecs.open('persondata_wkd_uris_pt.ttl', 'r', 'utf-8') as f_in, codecs.open('persondata_wkd_uris_pt.ttl.out', 'w', 'utf-8') as f_out:
for i, line in enumerate(f_in):
s1.setInterrogative(YES_NO);
// Did the boys leave home?
s1.setInterrogative(WHERE, OBJECT);
// Where did the boys leave?
Phrase s1 = new SPhraseSpec(‘leave’);
s1.setTense(PAST);
s1.setObject(new NPPhraseSpec(‘the’, ‘house’));
Phrase s2 = new StringPhraseSpec(‘the boys’);
s1.setSubject(s2);