Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 20-06-2019
bucanero bucanero is offline
Miembro
 
Registrado: nov 2013
Ubicación: Almería, España
Posts: 208
Poder: 11
bucanero Va camino a la fama
hola

aquí te dejo otra solución que te puede funcionar

Código Delphi [-]
  
  procedure loadFileContent(const AFileName:String);
  var
    text: TStreamReader;
    slinea: string;
  begin
    try
      text := TStreamReader.Create(AFileName, TEncoding.Default, true);
      while not text.EndOfStream do begin
        slinea := text.ReadLine;
        ProcesarLinea(slinea);
      end;
    finally
      text.Free;
    end;
  end;

var
  FileName: string;
begin
    FileName := 'c:\tmp\BueCont_TXT.txt';
    loadFileContent(FileName);
end;

y si lo que quieres es separar los campos incluidos dentro del propio fichero puedes hacerlo de una forma relativamente fácil de esta manera:
Código Delphi [-]

var
  parser: TStringList;

  procedure ProcesarLinea(const ALinea: string);
  var
    Ruc, nombre, razon, fecha, resolucion: string;
  begin
    parser.DelimitedText := '"' + ALinea.Replace('"', '""').Replace('|', '"|"') + '"';

    if parser.Count >= 5 then begin
      Ruc := parser.Strings[0];
      nombre := parser.Strings[1];
      razon := parser.Strings[2];
      fecha := parser.Strings[3];
      resolucion := parser.Strings[4];
    end;

    Memo1.Lines.Add(Ruc + #9 + nombre + #9 + razon + #9 + fecha + #9 + resolucion);
  end;

var
  FileName: string;
begin
  try
    parser := TStringList.Create;
    parser.StrictDelimiter := True;
    parser.Delimiter := '|';

    FileName := 'c:\tmp\BueCont_TXT.txt';
    loadFileContent(FileName);
  finally
    parser.Free;
  end;
end;

saludos
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Funcion para extraer texto de archivos de texto JuanOrtega Varios 5 24-02-2015 12:08:23
XML vs archivos de texto jordan23 Varios 5 17-08-2007 19:18:06
Leer varios archivos de texto y extraer solo 2 lineas de ese texto mp3968 Internet 1 17-05-2007 20:24:09
Archivos de texto yekkita Varios 4 19-01-2007 20:06:03
archivos de texto ssanchez Varios 1 19-01-2007 15:44:34


La franja horaria es GMT +2. Ahora son las 11:22:38.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi