Página 1 de 1
What's a good way to load substrings of a text file into a grid?
Publicado: Mié Dic 08, 2021 6:28 pm
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?
Re: What's a good way to load substrings of a text file into a grid?
Publicado: Mié Dic 08, 2021 6:53 pm
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,
Re: What's a good way to load substrings of a text file into a grid?
Publicado: Mié Dic 08, 2021 7:39 pm
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,
Re: What's a good way to load substrings of a text file into a grid?
Publicado: Jue Dic 09, 2021 11:14 am
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,
Re: What's a good way to load substrings of a text file into a grid?
Publicado: Jue Dic 09, 2021 4:29 pm
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,
Re: What's a good way to load substrings of a text file into a grid?
Publicado: Jue Dic 09, 2021 4:56 pm
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,
Re: What's a good way to load substrings of a text file into a grid?
Publicado: Jue Dic 09, 2021 5:36 pm
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,
Re: What's a good way to load substrings of a text file into a grid?
Publicado: Jue Dic 09, 2021 5:46 pm
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.
Re: What's a good way to load substrings of a text file into a grid?
Publicado: Jue Dic 09, 2021 6:41 pm
por ignacio
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,
Re: What's a good way to load substrings of a text file into a grid?
Publicado: Lun Dic 13, 2021 4:42 pm
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,
Re: What's a good way to load substrings of a text file into a grid?
Publicado: Mié Dic 15, 2021 2:33 pm
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,
Re: What's a good way to load substrings of a text file into a grid?
Publicado: Mié Dic 15, 2021 3:42 pm
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,