Board index » cppbuilder » Using text file as a database ?!!
T.Walker
![]() CBuilder Developer |
T.Walker
![]() CBuilder Developer |
Using text file as a database ?!!2003-07-31 07:44:01 PM cppbuilder37 Hi All, I want to store data I collect using my application but I don't need to use a database driver, so I was thinking of using a text file instead. But I didn't deal with text files before (working with it as if I'm working with a database file) I need to perform save(insertion), update, delete and search stored data I need to know if it is possible and if so how should I start and how would I get a resource for this subject thanks |
Hans Galema
![]() CBuilder Developer |
2003-07-31 11:28:02 PM
Re:Using text file as a database ?!!
T.Walker wrote:
QuoteI want to store data I collect using my application but I don't need to use data, not to much tables, not to much records, not to much relations ? Could you give an indication ? Quoteso I was thinking of using a text file instead. QuoteBut I didn't deal with text files before (working with it as if I'm working A record in the table would be a line in the txtfile and a String in the StringList. The StringList provides Add(), Insert(), Sorted/Unsorted, a CustomSort (bcb5 up), SaveToFile() and LoadFromFile(). QuoteI need to know if it is possible and if so how should I start and how would |
JD
![]() CBuilder Developer |
2003-08-01 02:23:12 AM
Re:Using text file as a database ?!!
Hans Galema < XXXX@XXXXX.COM >wrote:
QuoteIf you take a TStringList then the STringList could load the with a flat file of structures with text and ints and doubles? ~ JD {smallsort} |
Hans Galema
![]() CBuilder Developer |
2003-08-01 02:58:48 AM
Re:Using text file as a database ?!!
JD wrote:
QuoteHere we go with StringList again !!! QuoteActually, it's a nice as text. The fields can be separated with komma's. This is widely done with csv: comma separated value. A structure would be a record on its own. Hans. |
DRE
![]() CBuilder Developer |
2003-08-01 03:18:11 AM
Re:Using text file as a database ?!!
I'm having a very similler problem here
I'm working on a small application so I don't want to install a database driver with my app. So I was thinking of something like using a text file but some says that using XML is much much better and I still didn't make my mind which of them is better and I haven't work with any of both before I'm working on BCB 5 ent. thanks in advance "Hans Galema" < XXXX@XXXXX.COM >wrote in message QuoteJD wrote: |
Hans Galema
![]() CBuilder Developer |
2003-08-01 04:11:27 AM
Re:Using text file as a database ?!!
DRE wrote:
QuoteSo I was thinking of something like using a text file but some says that name,age,bcbversion Jack,23,3 Martin,44,5 And in xml: <record> <name>Jack</name> <age>23</age> <bcbversion>3</bcbversion> </record> <record> <name> Martin </name> <age>44</age> <bcbversion>5</bcbversion> </record> xml is in, and very handy. It takes much (file)space. It is not difficult to make functions like AnsiString get_record ( int recnr ); AnsiString get_item ( recnr, "age" ); Quoteand I still didn't make my mind which of them is better TStringList is handy for csv as every record is a String. Using xml you have more overhead I think. But once you wrote the basic insert and retrievel functions it's ok. Hans. |
JD
![]() CBuilder Developer |
2003-08-01 06:24:55 AM
Re:Using text file as a database ?!!
Hans Galema < XXXX@XXXXX.COM >wrote:
Quote[...] Using xml you have more overhead I think. But once you data to a new application in the future, XML may be the way to go. ~ JD |
Joe Vasher
![]() CBuilder Developer |
2003-08-01 10:03:53 AM
Re:Using text file as a database ?!!
When xml is used only waisted space is used in the text file when loaded you
would write routines that converted the xml file into a structure ??? Just as you would with the coma sep version ??? both would handle dynamic strings well ??? The xml version would only be overhead heavy in the case of large records with many items ??? Also isn't there built in function that can be used in cbuilder or microsoft to work with xml as with csv ??? "Hans Galema" < XXXX@XXXXX.COM >wrote in message QuoteDRE wrote: |
JD
![]() CBuilder Developer |
2003-08-01 02:09:59 PM
Re:Using text file as a database ?!!
"Joe Vasher" < XXXX@XXXXX.COM >wrote:
QuoteWhen xml is used only waisted space is used in the text file once parsed, would also need to be converted to an int or double ect. QuoteJust as you would with the coma sep version ??? However, a comma seperated file *seems* to be more easily parsed (I haven't parsed XML): StringList1->LoadFromFile( "SomeFile" ); StringList2->CommaText( StringList1->Strings[ RecordIndex ] ); Now list2 contains all of the fields for the RecordIndex record parsed into individual strings. You can loop through them and set the values for the desired structure. Quoteboth would handle dynamic strings well ??? QuoteThe xml version would only be overhead heavy in the case of QuoteAlso isn't there built in function that can be used in depreciated any time soon because of it's simplicity. Many programs accept this format for importing data. XML is much more current and while some programs also accept this format for importing, it's more widely used with SDK's and COM objects to transfere data between programs at runtime. ~ JD |
Hans Galema
![]() CBuilder Developer |
2003-08-01 03:00:25 PM
Re:Using text file as a database ?!!
JD wrote:
QuoteStringList1->LoadFromFile( "SomeFile" ); from a separator) is escaped. "Hey Joe\, how are you?" How would you handle that in a TStringList ? Hans. |
JD
![]() CBuilder Developer |
2003-08-01 04:38:24 PM
Re:Using text file as a database ?!!
Hans Galema < XXXX@XXXXX.COM >wrote:
Quote
~ JD |
Hans Galema
![]() CBuilder Developer |
2003-08-01 05:11:28 PM
Re:Using text file as a database ?!!
JD wrote:
QuoteWhen I created the string to be written to a file, I would have just removed the slash but kept the quotes. CommaText would then return: That's even better. Hans. |
JD
![]() CBuilder Developer |
2003-08-01 05:24:55 PM
Re:Using text file as a database ?!!
Hans Galema < XXXX@XXXXX.COM >wrote:
Quote
on water you know.". She replied "No. You just know where the stones are.". Some one must have moved one of my stones ;-) QuoteOh, so when commas are between quotes, then they are double quotes in the text then use double double quotes: ""Hey Joe, how are you?"" ~ JD P.S. If you want to use the quote, credit B. Huglin 2003 |
JD
![]() CBuilder Developer |
2003-08-01 05:43:14 PM
Re:Using text file as a database ?!!
Hans Galema < XXXX@XXXXX.COM >wrote:
QuoteJD wrote: If you want to know more about how CommaText parses, google for 'SDF formatted text'. ~ JD |
Hans Galema
![]() CBuilder Developer |
2003-08-01 05:51:47 PM
Re:Using text file as a database ?!!
JD wrote:
QuoteIf you want to know more about how CommaText parses, google for |