This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Script para juntar colunas de 2 arquivos com mesmo número de linhas em um só | |
import pandas as pd | |
import csv | |
# Abrir arquivos com colunas separadas por ";" e decimais por "," | |
df1 = pd.read_csv('dados.csv',delimiter=';',decimal=',') | |
df2 = pd.read_csv('outros_dados.csv',delimiter=';',decimal=',') | |
# Concatenar colunas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Iniciar tabela vazia | |
tabela = data.frame() | |
# Cortar período | |
serie_model = subset(dados, data > ini_model) | |
# Último mês de uma sequência de 14 meses | |
ultimo_mes_prev = tail(seq(as.Date(fim_model), by = "month", length = 14),n=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example of Conditional statements using lambda funtion | |
dates = ['2019-02-20','2019-02-21','2019-02-22'] | |
td = '2019-02-21' | |
i = 0 | |
# Conditional statement | |
if dates[i] < td: | |
print('obs') | |
else: | |
print('prev') | |
# Conditional statement with lambda |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from subprocess import check_output | |
# List files using pattern and get most recent | |
bashCommand = ("ls -1t %s/saida/arquivos_clientes/cn*.txt | head -1" %path) | |
# Define file name as last string, striping by '/' | |
filename = str(check_output(bashCommand, shell=True).strip(), 'utf-8') | |
remoteFileName = filename.split('/')[-1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_all_df(self, df): | |
with pd.option_context('display.max_rows', None, 'display.max_columns', None): | |
print(df) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
random.seed(42) | |
df['column_name'] = df['column_name'].apply(lambda v: random.random() * 100) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openssl rand -base64 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diretorio = '/home/user/model' | |
uid = 1 | |
filename = sprintf('%s/saida/saida_%s/prevaz_%s.csv', diretorio, 'semanal', uid) | |
values = tryCatch(read.csv(filename,as.is = TRUE), | |
error = function(e) NA, warning = function(w) print('Without semanal file')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
envio_email(){ | |
# Escrever corpo do e-mail | |
echo "Seguem anexos" >> $arq_email | |
printf "\n" >> $arq_email | |
# Arquivo de texto no corpo de e-mail | |
cat $arq_descr >> $arq_email | |
# Criar lista de e-mails a partir de arquivo | |
readarray -t lista_emails < <(cat $DIR/helpers/destinatarios_teste.txt | grep $grupo | awk -F',' '{print $1}') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ls *VS00* *VSS.* | zip -@ saida/arquivo.zip |