Compare commits
2 Commits
969e704edb
...
3fde1296ee
| Author | SHA1 | Date | |
|---|---|---|---|
| 3fde1296ee | |||
| 43d68b2c67 |
Binary file not shown.
+6
-3
@@ -55,6 +55,9 @@ def listar_pastas(diretorio):
|
||||
|
||||
def carregar_arquivoxls_mais_proxima():
|
||||
print("Carregando arquivo...")
|
||||
print("TEM QUE ABRIR O ARQUIVOB E VERIFICAS AS COORDENADAS...")
|
||||
|
||||
|
||||
diretorio = 'data' # nome da pasta principal
|
||||
|
||||
destino= "11estacaoproxima"
|
||||
@@ -81,7 +84,7 @@ def calcular_distancia(lat1, lon1, lat2, lon2):
|
||||
|
||||
def processar_arquivos_xls(arquivo, output_csv):
|
||||
|
||||
db = pd.read_excel(arquivo, decimal='.')
|
||||
db = pd.read_excel(arquivo, decimal='.') #LENDO PONTO
|
||||
|
||||
|
||||
db.columns = db.columns.str.strip()
|
||||
@@ -98,11 +101,11 @@ def processar_arquivos_xls(arquivo, output_csv):
|
||||
print("Uma ou mais colunas esperadas não estão presentes no DataFrame.")
|
||||
|
||||
|
||||
df.to_csv(output_csv, sep=";", encoding='utf-8', decimal=',', index=False)
|
||||
df.to_csv(output_csv, sep=";", encoding='utf-8', decimal='.', index=False)
|
||||
|
||||
|
||||
def processar_arquivos_xls2(output_csv):
|
||||
df = pd.read_csv(output_csv, encoding='utf-8', sep=';', decimal=',')
|
||||
df = pd.read_csv(output_csv, encoding='utf-8', sep=';', decimal='.')
|
||||
df['1p'] = ''
|
||||
df['2p'] = ''
|
||||
df['3p'] = ''
|
||||
|
||||
Binary file not shown.
+17
-12
@@ -57,19 +57,24 @@ def estacaochuvosa(dados, output_csv):
|
||||
|
||||
|
||||
try:
|
||||
dados['VALOR'] = dados['VALOR'].astype(str) # Garantir que todos os valores são strings
|
||||
|
||||
# Substituir vírgulas por pontos
|
||||
dados['VALOR'] = dados['VALOR'].str.replace(',', '.', regex=False)
|
||||
|
||||
# Converter a coluna 'VALOR' para float
|
||||
dados['VALOR'] = pd.to_numeric(dados['VALOR'], errors='coerce')
|
||||
|
||||
# Garantir que os valores numéricos estão corretos antes de processar
|
||||
dados_df['VALOR'] = dados_df['VALOR'].astype(str).str.replace(',', '.')
|
||||
|
||||
# Verificar se alguma linha ainda tem valores inválidos antes da conversão
|
||||
for index, valor in dados_df['VALOR'].items():
|
||||
try:
|
||||
dados_df.at[index, 'VALOR'] = float(valor)
|
||||
except ValueError:
|
||||
print(f"Erro ao converter 'VALOR' na linha {index + 2}: '{valor}'") # +2 pois index começa em 0 e CSV tem cabeçalho
|
||||
|
||||
# Converter a coluna inteira para float após a verificação
|
||||
dados_df['VALOR'] = dados_df['VALOR'].astype(float)
|
||||
|
||||
# Tratar valores NaN substituindo por 0
|
||||
dados['VALOR'] = dados['VALOR'].fillna(0)
|
||||
|
||||
dados_df['VALOR'] = dados_df['VALOR'].fillna(0)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Erro ao converter a coluna 'VALOR': {e}")
|
||||
print(f"Erro geral ao converter a coluna 'VALOR': {e}")
|
||||
|
||||
|
||||
|
||||
@@ -113,7 +118,7 @@ def estacaochuvosa(dados, output_csv):
|
||||
for index, row in df_inciochuva.iterrows():
|
||||
# print(index, ' ', row)
|
||||
|
||||
leitura_chuva = row['VALOR']#float(row['VALOR'].replace(',', '.'))
|
||||
leitura_chuva = float(row['VALOR'])#float(row['VALOR'].replace(',', '.'))
|
||||
|
||||
if leitura_chuva>=0:
|
||||
somador_ml= somador_ml+leitura_chuva
|
||||
|
||||
Binary file not shown.
|
Can't render this file because it is too large.
|
|
Can't render this file because it is too large.
|
|
Can't render this file because it is too large.
|
|
Can't render this file because it is too large.
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
,felipe,pop-os,22.03.2025 15:50,file:///home/felipe/.config/libreoffice/4;
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+27
-14
@@ -12,7 +12,7 @@ def listar_pastas(diretorio):
|
||||
def completar_com_valores_menos_um(dados, estacao, output):
|
||||
|
||||
|
||||
dados_df = pd.read_csv(dados, sep=';', decimal=',', parse_dates=['DATA'], dayfirst=True)
|
||||
dados_df = pd.read_csv(dados, sep=';', decimal='.', parse_dates=['DATA'], dayfirst=True)
|
||||
start_date = '1980-01-01'
|
||||
end_date = '2024-12-31'
|
||||
|
||||
@@ -21,7 +21,7 @@ def completar_com_valores_menos_um(dados, estacao, output):
|
||||
dados_df=filtered_df
|
||||
|
||||
dados_df.head(2)
|
||||
estacao_df = pd.read_csv(estacao, encoding='utf-8', sep=';', decimal=',')
|
||||
estacao_df = pd.read_csv(estacao, encoding='utf-8', sep=';', decimal='.')
|
||||
estacao_df.head(2)
|
||||
|
||||
|
||||
@@ -47,8 +47,17 @@ def completar_com_valores_menos_um(dados, estacao, output):
|
||||
# Iterar sobre AtualizaDados para atualizar os valores
|
||||
for index, row in AtualizaDados.iterrows():
|
||||
print(f"\rProcessando linha {index+1}/{total}", end='')
|
||||
valor = row['VALOR']
|
||||
|
||||
valor_str = row['VALOR'].replace(',', '.') # Substitui vírgula por ponto
|
||||
try:
|
||||
valor = float(valor_str) # Converte para número
|
||||
except ValueError:
|
||||
print(f"Erro ao converter o valor: {row['VALOR']}")
|
||||
valor = -1 # Define um valor padrão ou trata o erro de outra forma
|
||||
|
||||
data = row['DATA']
|
||||
|
||||
|
||||
if valor <= -1:
|
||||
|
||||
log_file.write(f"Código: {row['CODIGO']}, Data: {row['DATA']}, Valor: {valor}\n")
|
||||
@@ -64,18 +73,22 @@ def completar_com_valores_menos_um(dados, estacao, output):
|
||||
|
||||
log_file.write(f"{i}codigo: {codigo_proximo} Valor: {valor_proximo}\n")
|
||||
|
||||
# Verificar se o valor encontrado não é menor ou igual a -1
|
||||
if len(valor_proximo) > 0 and valor_proximo[0] > -1:
|
||||
AtualizaDados.loc[index, 'VALOR'] = valor_proximo[0]
|
||||
ultimo_codigo_achado = codigo_proximo
|
||||
ultimo_valor_atualizado = valor_proximo[0]
|
||||
if len(valor_proximo) > 0:
|
||||
try:
|
||||
valor_num = float(valor_proximo[0].replace(',', '.')) # Converte para número
|
||||
if valor_num > -1:
|
||||
AtualizaDados.loc[index, 'VALOR'] = valor_num
|
||||
ultimo_codigo_achado = codigo_proximo
|
||||
ultimo_valor_atualizado = valor_num
|
||||
|
||||
log_file.write(f"Valor atual {row['VALOR']} - Valor atualizado para: {valor_proximo[0]}\n")
|
||||
|
||||
break # Parar o loop se encontrar um valor válido
|
||||
else:
|
||||
log_file.write(f"****Não achou o valor \n")
|
||||
somente_valores_menores_ou_igual_a_menos_um = True
|
||||
log_file.write(f"Valor atual {row['VALOR']} - Valor atualizado para: {valor_num}\n")
|
||||
break # Parar o loop se encontrar um valor válido
|
||||
except ValueError:
|
||||
log_file.write(f"****Erro ao converter valor_proximo: {valor_proximo[0]}\n")
|
||||
|
||||
# Caso não encontre um valor válido
|
||||
log_file.write(f"****Não achou o valor \n")
|
||||
somente_valores_menores_ou_igual_a_menos_um = True
|
||||
|
||||
log_info.append({
|
||||
'CODIGO': row['CODIGO'],
|
||||
|
||||
Reference in New Issue
Block a user