Skip to content

PS Z:\Projetos\ESP32> #4923

@wilsontec1989-instru

Description

@wilsontec1989-instru

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.

Exception report

Últimas 200 Chaves:
 s \ i n s t r u m e n t a c a o . b a r r a \ A p p D a t a \ L o c a l \ P r o g r a m s \ P y t h o n \ P y t h o n 3 1 4 \ p y t h o n . e x e ' Space ' c : \ U s e r s \ i n s t r u m e n t a c a o . b a r r a \ . v s c o d e \ e x t e n s i o n s \ m s - p y t h o n . d e b u g p y - 2 0 2 5 . 1 0 . 0 - w i n 3 2 - x 6 4 \ b u n d l e d \ l i b s \ d e b u g p y \ l a u n c h e r ' Space ' 5 7 8 7 1

Exceção:
System.ArgumentOutOfRangeException: O valor deve ser maior ou igual a zero e menor que o tamanho do buffer do console nessa dimensão.       
Nome do parâmetro: left
Valor real era -2.
   em Microsoft.PowerShell.Internal.VirtualTerminal.set_CursorLeft(Int32 value)
   em Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
   em Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
   em Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c)
   em Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable`1 key, Object arg)
   em Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object 
arg)
   em Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   em Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)
-----------------------------------------------------------------------
PS Z:\Projetos\ESP32>  & 'c:\Users\instrumentacao.barra\AppData\Local\Programs\Python\Python314\python.exe' 'c:\Users\instrumentacao.barra\.vscode\extensions\ms-python.debugpy-2025.10.0-win32-x64\bundled\libs\debugpy\launcher' '57871' '--' 'Z:\Projetos\ESP32\import os.py'

Screenshot

Exceção:
System.ArgumentOutOfRangeException: O valor deve ser maior ou igual a zero e menor que o tamanho do buffer do console nessa dimensão.
Nome do parâmetro: left
Valor real era -2.
em Microsoft.PowerShell.Internal.VirtualTerminal.set_CursorLeft(Int32 value)
em Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
em Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
em Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c)
em Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable1 key, Object arg) em Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary2 dispatchTable, Boolean ignoreIfNoAction, Object
arg)
em Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
em Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)

PS Z:\Projetos\ESP32> & 'c:\Users\instrumentacao.barra\AppData\Local\Programs\Python\Python314\python.exe' 'c:\Users\instrumentacao.barra.vscode\extensions\ms-python.debugpy-2025.10.0-win32-x64\bundled\libs\debugpy\launcher' '57871' '--' 'Z:\Projetos\ESP32\import os.py'

Environment data

def processar_documentos():
    # Cria a pasta de documentos se ela não existir
    if not os.path.exists(DIRETORIO_DOCUMENTOS):
        os.makedirs(DIRETORIO_DOCUMENTOS)
        print(f"Pasta '{DIRETORIO_DOCUMENTOS}' criada. Adicione seus arquivos aqui.")
        return

    novos_dados_os = []

Steps to reproduce

Lista todos os arquivos na pasta

for nome_arquivo in os.listdir(DIRETORIO_DOCUMENTOS):
    caminho_completo = os.path.join(DIRETORIO_DOCUMENTOS, nome_arquivo)
    
    # Ignora pastas e processa apenas arquivos de imagem ou PDF
    if os.path.isfile(caminho_completo):
        print(f"Processando arquivo: {nome_arquivo}")
        texto_extraido = extrair_dados_ocr(caminho_completo)
        
        if texto_extraido:
            dados_os = parse_texto_os(texto_extraido)
            dados_os["Arquivo_Origem"] = nome_arquivo
            novos_dados_os.append(dados_os)

Expected behavior

# --- ATUALIZANDO O ARQUIVO EXCEL ---
if not novos_dados_os:
    print("Nenhum novo documento encontrado para processar.")
    return

Actual behavior

df_novos_dados = pd.DataFrame(novos_dados_os)

# Verifica se o arquivo de banco de dados já existe
if os.path.exists(ARQUIVO_BANCO_DADOS):
    # Lê o arquivo existente para adicionar os novos dados
    df_existente = pd.read_excel(ARQUIVO_BANCO_DADOS)
    
    # Combina os dataframes. Note que a combinação pode gerar duplicatas se o mesmo arquivo
    # for processado duas vezes. Uma melhoria seria verificar se o 'Arquivo_Origem' já existe.
    df_final = pd.concat([df_existente, df_novos_dados], ignore_index=True)
    # Remove duplicatas baseadas na coluna 'Arquivo_Origem'
    df_final.drop_duplicates(subset=['Arquivo_Origem'], keep='last', inplace=True)
    
else:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions