In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

What's a good way to load substrings of a text file into a grid?

Xailer professional forum in English
Responder
DC
Mensajes: 122
Registrado: Lun May 16, 2011 6:06 pm

What's a good way to load substrings of a text file into a grid?

Mensaje por DC »

Hi, I just need the general approach, and what kind of grid to use.

So if we have a fixed-width text file with defined fields or a comma delimited file, what kind of grid should we use? Just a basic TListView?

How would you reccomend to navigate through the file? Just use the basic Harbour file functions?
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9252
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: What's a good way to load substrings of a text file into a grid?

Mensaje por ignacio »

Hi,

It depends on how you want the information to be seen. If is a typical row & columns data, I suggest you use a Browse. Is quite easy to move the data to an array with hb_tokens() functions. In case not, use a standard TMemo using a non proportional font, like Courier. If the file size is huge, consider using a TRichedit, since it handles large files better.

Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
DC
Mensajes: 122
Registrado: Lun May 16, 2011 6:06 pm

Re: What's a good way to load substrings of a text file into a grid?

Mensaje por DC »

Thanks ignaacio,

Yes, it would be viewed in columns of data.

Would we be using a Tbrowse or TArrayBrowse, or some other component?

If we use a browse, does the array get loaded a screen at a time? I'd be concerned about performance when the files are really large.

It would be read-only, not sure if that makes a difference.

ignacio escribió: Mié Dic 08, 2021 6:53 pm Hi,

It depends on how you want the information to be seen. If is a typical row & columns data, I suggest you use a Browse. Is quite easy to move the data to an array with hb_tokens() functions. In case not, use a standard TMemo using a non proportional font, like Courier. If the file size is huge, consider using a TRichedit, since it handles large files better.

Regards,
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9252
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: What's a good way to load substrings of a text file into a grid?

Mensaje por ignacio »

Hi,

When I say huge files, I mean files over 10 Mb, or so. Except those cases you surely will not detect any speed problem on converting that file into an array. In case the file is larger, I recommend to use a TBrowse, its navigation events and the harbour file functions: fopen(), fseek(), ....

Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
DC
Mensajes: 122
Registrado: Lun May 16, 2011 6:06 pm

Re: What's a good way to load substrings of a text file into a grid?

Mensaje por DC »

Ok, thanks Ignacio. Some of the files are at least a gig.
ignacio escribió: Jue Dic 09, 2021 11:14 am Hi,

When I say huge files, I mean files over 10 Mb, or so. Except those cases you surely will not detect any speed problem on converting that file into an array. In case the file is larger, I recommend to use a TBrowse, its navigation events and the harbour file functions: fopen(), fseek(), ....

Regards,
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9252
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: What's a good way to load substrings of a text file into a grid?

Mensaje por ignacio »

Hi,

Then I suggest you treat them with just fOpen(), fSeek() and fClose() functions and a TBrowse control. The RecCount() surely will be the tricky part.

Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
DC
Mensajes: 122
Registrado: Lun May 16, 2011 6:06 pm

Re: What's a good way to load substrings of a text file into a grid?

Mensaje por DC »

I guess I'd want to start with the HB_F() functions, assuming that they behave well with Xailer.

https://vivaclipper.wordpress.com/tag/hb_fuse/

ignacio escribió: Jue Dic 09, 2021 4:56 pm Hi,

Then I suggest you treat them with just fOpen(), fSeek() and fClose() functions and a TBrowse control. The RecCount() surely will be the tricky part.

Regards,
DC
Mensajes: 122
Registrado: Lun May 16, 2011 6:06 pm

Re: What's a good way to load substrings of a text file into a grid?

Mensaje por DC »

Ignacio,

Sorry, I can't locate a TBrowse component in any of the toolbox tabs. Should I just use the class directly?

The derived objects are there TArrayBrowse and TDBBrowse and such. But there's no base component TBrowse.
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9252
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: What's a good way to load substrings of a text file into a grid?

Mensaje por ignacio »

DC escribió: Jue Dic 09, 2021 5:36 pm I guess I'd want to start with the HB_F() functions, assuming that they behave well with Xailer.
https://vivaclipper.wordpress.com/tag/hb_fuse/
No way. They are extremely slow:
- Memoread() loads the complete file to a memory string.
- Memoline() is the slowest function ever done.

You must NOT load the file into memory. You should only load chuncks of that file. That's the way.

Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9252
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: What's a good way to load substrings of a text file into a grid?

Mensaje por ignacio »

Hi,

Attached a sample using a browser class TTextBrowse that can handles any text file of any size, as long the OS can handle too.

With REALLY very large files, the function GetLines() can be slow. Moving that function to C surely will increase its speed. Another possibility is to use a TFuture for that code.

Regards,
Adjuntos
test.zip
(3.62 KiB) Descargado 75 veces
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
DC
Mensajes: 122
Registrado: Lun May 16, 2011 6:06 pm

Re: What's a good way to load substrings of a text file into a grid?

Mensaje por DC »

I didn't expect this. Thanks, Ignacio.

ignacio escribió: Lun Dic 13, 2021 4:42 pm Hi,

Attached a sample using a browser class TTextBrowse that can handles any text file of any size, as long the OS can handle too.

With REALLY very large files, the function GetLines() can be slow. Moving that function to C surely will increase its speed. Another possibility is to use a TFuture for that code.

Regards,
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9252
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: What's a good way to load substrings of a text file into a grid?

Mensaje por ignacio »

DC escribió: Mié Dic 15, 2021 2:33 pm I didn't expect this. Thanks, Ignacio.
Glad to help to active Xailer users. Thank you for your support.

Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Responder