Recent

Author Topic: Tab delimited text file as a database?  (Read 1003 times)

backprop

  • Jr. Member
  • **
  • Posts: 94
Tab delimited text file as a database?
« on: July 15, 2024, 03:11:52 pm »
I see there is CSV, DBF, some fixed format database and similar, but is there a way to use tab delimited text file as a database and related DB components?

wp

  • Hero Member
  • *****
  • Posts: 12410
Re: Tab delimited text file as a database?
« Reply #1 on: July 15, 2024, 03:23:03 pm »
I think you can use the TSDFDataset and set  its Delimiter to #9.

https://wiki.freepascal.org/TSdfDataSet
https://wiki.freepascal.org/CSV#SDFDataset

Be careful in reading because the latter wiki article also refers to the TFixedFormatDataset which has a different structure.

backprop

  • Jr. Member
  • **
  • Posts: 94
Re: Tab delimited text file as a database?
« Reply #2 on: July 15, 2024, 05:13:43 pm »
Thanks, it seems to works...

Additionally, I need that any change (after edit, insert and delete) be updated in the file. But I do not see commit method for dataset. Commit is only performed automatically on closing dataset.

Thaddy

  • Hero Member
  • *****
  • Posts: 15979
  • Censorship about opinions does not belong here.
Re: Tab delimited text file as a database?
« Reply #3 on: July 15, 2024, 06:15:56 pm »
DisableControls;
active:=false;
//sleep(10);
active:= true;
EnableControls;

But if TSDFDataset supports refresh, simply call refresh..
(I would use TCSVdataset, instead, that is much more complete)
If I smell bad code it usually is bad code and that includes my own code.

backprop

  • Jr. Member
  • **
  • Posts: 94
Re: Tab delimited text file as a database?
« Reply #4 on: July 15, 2024, 06:53:00 pm »
You have no clue what I asked, thus do not bother...

DisableControls;
active:=false;
//sleep(10);
active:= true;
EnableControls;

But if TSDFDataset supports refresh, simply call refresh..
(I would use TCSVdataset, instead, that is much more complete)

wp

  • Hero Member
  • *****
  • Posts: 12410
Re: Tab delimited text file as a database?
« Reply #5 on: July 15, 2024, 07:07:35 pm »
Would SDFDataset.SaveFileAs(filename) or .SaveToStream(stream) do?

JanRoza

  • Hero Member
  • *****
  • Posts: 699
    • http://www.silentwings.nl
Re: Tab delimited text file as a database?
« Reply #6 on: July 15, 2024, 07:24:16 pm »
Quote
You have no clue what I asked, thus do not bother...
That's a rather unfriendly reaction on a very sensible answer.
With that attitude I don't think you'll not get much help here.
OS: Windows 11 / Linux Mint 22
       Lazarus 4.0 RC FPC 3.2.2
       CodeTyphon 8.50 FPC 3.3.1

backprop

  • Jr. Member
  • **
  • Posts: 94
Re: Tab delimited text file as a database?
« Reply #7 on: July 15, 2024, 07:29:56 pm »
That's a rather unfriendly reaction on a very sensible answer.
With that attitude I don't think you'll not get much help here.

He rudely insulted me many times all active members can recall that even these messages are deleted by moderator. What you will expect? To be polite with him?

He have no clue what I asked and certainly I have not asked him. His answer is useless, anyway.


backprop

  • Jr. Member
  • **
  • Posts: 94
Re: Tab delimited text file as a database?
« Reply #8 on: July 16, 2024, 07:05:43 am »
Would SDFDataset.SaveFileAs(filename) or .SaveToStream(stream) do?

That should do it, if file itself if not protected for changing when opened. I will test, thank you.

 

TinyPortal © 2005-2018