Help with TXT File please

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
Jose Marte2
Posts: 45
Joined: Thu Nov 16, 2017 2:19 pm
Location: República Dominicana

Help with TXT File please

#1 Post by Jose Marte2 »

Hello, greetings to all, I hope you are well. Please can someone help me? I have a .txt file with thousands of records. I read or open the file with DC_TXTOPEN and then I look in the file with DC_TXTFIND, the problem is that the search is positioned in the first record it finds and I need to find the record that I'm passing it specifically.

Example:

nHandleRnc: = DC_TxtOpen ('c: \ sisadco \ rnc \ dgii_rnc.txt')
nRnc: = DC_TXTFIND (nHandleRnc, AllTrim (cCliRnc) ,. t.)
cRazon: = ""

the cCliRnc field can be of 9 or 11 characters and if DC_TXTFIND finds a record of 11 that contains the nine characters that I am sometimes looking for there is the problem. How to search for the record that I sent you specifically. The anticipated Thanks. I hope to have explained to me the best possible, but you can ask me again. Thank you.
José Marte
Software & Servicios


reganc
Posts: 257
Joined: Thu Jan 28, 2010 3:08 am
Location: Hersham, Surrey, UK
Contact:

Re: Help with TXT File please

#2 Post by reganc »

Jose Marte2 wrote:Hello, greetings to all, I hope you are well. Please can someone help me? I have a .txt file with thousands of records. I read or open the file with DC_TXTOPEN and then I look in the file with DC_TXTFIND, the problem is that the search is positioned in the first record it finds and I need to find the record that I'm passing it specifically.

Example:

nHandleRnc: = DC_TxtOpen ('c: \ sisadco \ rnc \ dgii_rnc.txt')
nRnc: = DC_TXTFIND (nHandleRnc, AllTrim (cCliRnc) ,. t.)
cRazon: = ""

the cCliRnc field can be of 9 or 11 characters and if DC_TXTFIND finds a record of 11 that contains the nine characters that I am sometimes looking for there is the problem. How to search for the record that I sent you specifically. The anticipated Thanks. I hope to have explained to me the best possible, but you can ask me again. Thank you.
You don't mention what the format of the text file containing your records is. Maybe you would be better reading the file line by line using DC_TXTLINE() in a loop.

You can then split each line into individual fields and check each field you want to match individually using whatever matching criteria you wish.
Regan Cawkwell
Real Business Applications Ltd
http://www.rbauk.com

patito
Posts: 121
Joined: Tue Aug 31, 2010 9:01 pm

Re: Help with TXT File please

#3 Post by patito »

Estimado

No indicas si el archivo de texto esta construido bajo un padrón o esquema fijo.
Podrias aclarar mas el tema, ya que tienes varias opciones de búsqueda
entre ellas at() etc.
Si es de un esquema fijo, tienes la posición en la columna

saludos
Héctor Pezoa

User avatar
Jose Marte2
Posts: 45
Joined: Thu Nov 16, 2017 2:19 pm
Location: República Dominicana

Re: Help with TXT File please

#4 Post by Jose Marte2 »

Greetings, thanks for taking a bit of your time to answer me, thank you, I value that very much. Here I am attaching a small example of the file, it is a large file of about 3,061,752 records and growing since it is the database of all the taxpayers here in my country RD that facilitates the DGII, that file I want to insert it into the program of billing and when a RNC or CEDULA is typed, look in the file to bring the name of the taxpayer and validate his status to be able to invoice him with NCF. The RNC or CEDULA can be of 9 or 11 characters. The problem is that when I search for a RNC or CEDULA of nine characters if it finds this field in a RNC or CEDULA of 11 characters there it stops and it brings me a name that does not correspond to the RNC or CEDULA digitado.

Saludos, gracias por tomarse un poco de su tiempo para contestarme, gracias, valoro mucho eso. Ahi le estoy adjuntando un ejemplo pequeño del archivo, es un archivo grande de como de 3,061,752 registro y creciendo ya que es la base de datos de todos los contribuyentes aqui en mi pais RD que facilita la DGII, ese archivo lo quiero insertar al programa de facturacion y cuando se digite un RNC o CEDULA buscar en el archivo para traer el nombre del contribuyente y validar su estatus para poder facturarle con NCF. Los RNC o CEDULA pueden ser de 9 u 11 caracteres. El problema es que cuando busco un RNC o CEDULA de nueve caracteres si encuentra este campo en un RNC o CEDULA de 11 caracteres ahi se detiente y me trae un nombre que no corresponde al RNC o CEDULA digitado.



Archivo TXT (Contenido Del Archivo)

04600235701|FRANCISCO ANTONIO SANTANA||MANTENIMIENTO Y REPARACIÓN DEL| | | | |25/06/1999|ACTIVO|NORMAL
00100322338|ISABEL YOLANDA VALENZUELA ROSARIO||SERVICIOS PERSONALES EN GENERA| | | | |25/06/1999|ACTIVO|NORMAL
531028378|COEN GARCIA SARAH JOSEFINA||OTROS NO CLASIFICADOS| | | | |25/06/1999|ACTIVO|NORMAL
501989895|GARCIA GELL JESUS SALVADOR||SERVICIOS PERSONALES EN GENERA| | | | |29/05/2003|ACTIVO|NORMAL
00117328690|WILIAN LEONEL DOTEL PEREZ||OPERACIONES INMOBILIARIAS, INV| | | | |28/10/2002|ACTIVO|NORMAL
00114432149|LUIS ELPIDIO SANTIAGO THEN||EMPLEADOS (ASALARIADOS) | | | | |19/06/2002|ACTIVO|NORMAL
00101262822|MERCEDES DE VARGAS CASTRO||ENSEÑANZA PRIMARIA| | | | |25/06/1999|ACTIVO|NORMAL
502611046|AZCONA RODRIGUEZ DE ESPINAL MARIA ALTAGRACIA||OPERACIONES INMOBILIARIAS, INV| | | | |25/06/1999|ACTIVO|NORMAL
00103716205|MARIA DE LOS ANGELES CASTILLO FERNANDEZ|COLMADO MARIA II|COLMADOS| | | | |04/06/2001|ACTIVO|NORMAL
00104792452|JOCELYNE DEL CARMEN TEJADA GISBERT||SERVICIOS DE ASESORAMIENTO, DI| | | | |16/06/1998|ACTIVO|PST
10000017524|JULIO ENRIQUE NOLASCO SOSA|AGROVETERINARIA DR. NOLASCO|SERVICIOS VETERINARIOS| | | | |17/10/2001|ACTIVO|NORMAL
00107272379|JUAN RAMON HEREDIA CASTILLO|CORREDORES DE SEGUROS|SERVICIOS INMOBILIARIOS REALIZ| | | | |21/12/1999|ACTIVO|NORMAL
04800501365|MARCIAL TINEO GARCIA|COLMADO TINEO|COLMADOS| | | | |17/06/1998|ACTIVO|NORMAL
501478442|BEGAZO DE LUGO JUSTA ELIZABETH||OPERACIONES INMOBILIARIAS, INV| | | | |17/06/1998|ACTIVO|NORMAL
03200020083|MARINO CASTRO||PRODUCCION DE BANANA| | | | |02/09/2002|ACTIVO|NORMAL
03101001208|PORFIRIA ANDREA SANCHEZ DE MARTINEZ||OPERACIONES INMOBILIARIAS, INV| | | | |21/11/1997|ACTIVO|NORMAL
00100055839|EDWIN AUGUSTO SOSA VIERA|SOVI COMERCIAL EDWIN SOSA|VENTA AL POR MENOR DE PARTES, | | | | |21/04/1999|ACTIVO|NORMAL
01100262698|TOMAS ENRIQUE CASTILLO GARCIA||EMPLEADOS (ASALARIADOS) | | | | |09/06/1998|ACTIVO|NORMAL
501475433|DAMIAN OSCAR MARIA||OPERACIONES INMOBILIARIAS, INV| | | | |09/06/1998|ACTIVO|NORMAL
01200071619|CRISTELA GERALDO||OPERACIONES INMOBILIARIAS, INV| | | | |09/06/1998|DADO DE BAJA|NORMAL
501475468|NOVOA MARTINEZ DE ENCARNACION TRINIDAD VIRGINIA||OPERACIONES INMOBILIARIAS, INV| | | | |09/06/1998|ACTIVO|NORMAL
03200120883|TOMAS BATISTA MERCADO||OPERACIONES INMOBILIARIAS, INV| | | | |04/06/2001|ACTIVO|NORMAL
01200400388|FRANCISCO CEDANO PEREZ||OPERACIONES INMOBILIARIAS, INV| | | | |09/06/1998|ACTIVO|NORMAL
01200368197|ANA BEATRIZ QUEZADA ROSARIO||OTROS SERVICIOS (ESTUDIANTES, | | | | |09/06/1998|ACTIVO|NORMAL
501476626|VARGAS DE TEJADA MANUELA DE JESUS||OPERACIONES INMOBILIARIAS, INV| | | | |09/06/1998|ACTIVO|NORMAL
José Marte
Software & Servicios


User avatar
Tom
Posts: 1171
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Help with TXT File please

#5 Post by Tom »

Hi, Jose.

A guy in the german Xbase++-forum posted the code for a textfile-reader class, which is very fast:

https://www.xbaseforum.de/viewtopic.php ... 61&p=88725

If you read your file line per line with this class (method "GetLine()"), you get a string for each line. You can use DC_TokenArray(cLine,"|") to split the lines at the marker "|" into a one-dim array and add this array to an array having two dims then. After all this is done, you can do a simple AScan() to find the lines with the number you're looking for - they all are in column 1.

You will get the same result if you collect the lines with DC_TxtLine() and add the result of DC_TokenArray() to an array, but maybe a little slower.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
Auge_Ohr
Posts: 1407
Joined: Wed Feb 24, 2010 3:44 pm

Re: Help with TXT File please

#6 Post by Auge_Ohr »

what about using SDFDBE :?:
greetings by OHR
Jimmy

patito
Posts: 121
Joined: Tue Aug 31, 2010 9:01 pm

Re: Help with TXT File please

#7 Post by patito »

Estimado Jose

Puedes hacer esto también

nHandle := DC_TxtOpen(cArchivo)) //<= 0
DC_TxtSkip(nHandle,1) // skip past first line ??

DO WHILE !DC_TxtEof(nHandle)
cTokens := DC_TxtLine(nHandle)
cTokens := StrTran(cTokens , Chr(9) , Chr(32) ) //ver si es necesario
aTokens := DC_TokenArray(cTokens,'|')

Luego lo grabas en una dbf

aTokens[1] = " 04600235701"
aTokens[2] = " FRANCISCO ANTONIO SANTANA "

etc
||MANTENIMIENTO Y REPARACIÓN DEL| | | | |25/06/1999|ACTIVO|NORMAL

enddo

Tambien puedes utilizar la libreria de Pablo Botella ot4xb
La funcion tokenize( 'C:\PPEPE\LOCO\FEO\PPP.TXT', '\' )
devuelve { c:, ppepe, loco, feo, ppp.txt }
normalmente en archivos de intercambio usas "|" como separador de campo
y crlf como separador de registro entonces si haces un tokenize( archivo, crlf )
tienes un array de registros y si luego por cada registro haces un
tokenize( cRegistro, '|' ) tienes los campos de ese registro
si luego haces el expando de ese registro, tienes la clase expando

y por ultimo dentro de la libreria ot4xb tambien esta la clase tbinfile():new()
parecida a Dc_txt

::m_reader := TBinFile():New()
::m_reader:ResetBuffer( 0x800000 )
result := ::m_reader:Open( cFilename ,"R","R",.F. )

saludos
Hector

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Help with TXT File please

#8 Post by Eugene Lutsenko »

And what if the formation of the search field to determine its size and complement some special characters to the maximum length (for example, underscore). Then the uniqueness of the search key will be provided and the record with the long key will never be found by its part

User avatar
Jose Marte2
Posts: 45
Joined: Thu Nov 16, 2017 2:19 pm
Location: República Dominicana

Re: Help with TXT File please

#9 Post by Jose Marte2 »

A thousand thanks for all for your help, excellent, thank you very much. I think I have what it takes to solve this problem.

Mil gracias para todos por su ayuda, excelente, mil gracias. Creo que tengo lo necesario para resolver este problema.
José Marte
Software & Servicios


Victorio
Posts: 621
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: Help with TXT File please

#10 Post by Victorio »

for read large txt files I use

nSourcestring := FRead( nHandle, @cSourceString, velkostsuboru )

but when file is very large 1GB or more, I must break file to parts and read separately.

When processing file (file is read to char variable) I need search EOL sign to found where line ends.

For read large files this system still have better performance in compare with DC_TXTLINE, but more code to processing ..

Post Reply