Version 16 of Anyone interested in doing a comma delimited database?

Updated 2006-06-06 11:32:31

Robert Abitbol Many years ago, in the glorious days of the pioneer DOS (we thought then Dos was the end of the world but by jolly! there was much more to come afterwards!), ['We thought' ? CMcC never thought of DOS as pioneering, or the endpoint of anything, merely a second-rate knockoff of a better system] there was an amazing database software called Rapid File programmed in Forth (another amazing programming language).

I suspect it was in fact a comma-delimited database therefore it was occupying close to nothing in terms of space. It was small, fast, elegant, innovative.

It was the kind of stuff RS would write.

See more here: http://c2.com/cgi/wiki?RapidFile (I wrote most of the text on that page).

I think Tcl/Tk would lend itself very well to such a database.

The beauty with Rapid File was that it had an incorporated editor; it was a word processor and a database. Another amazing feature: the snapshots: you could enter a database and decide to write a snapshot; a snapshot was simply a feature enabling a user to save a few selected fields, to sort them in a particular way at entry etc.

If anyone is interested in writing something similar in Tcl/Tk, let me know. My e-mail address is on my homepage.

This is a good project for an ambitious Tcler who wants to build, to program a great app to show to employers who want to see an example of his/her work.

More often than not, programmers can show bits and pieces of work but not complete apps; but when they can show slick, elegant and complete, excellent apps, employers are impressed and they hire them right away. Therefore whoever will work on this project will invest in his/her future.

This program could also be offered for download or sold.

Please note that I don't have the time to supervise or get involved in this project. I can offer some guidance and advice from time to time but that is about it.


See CSV for code to deal with comma-separated-values data files. LV Actually, csv allows the user to specify the character used for seperation, with the default being a comma if one doesn't specify. That takes care of the request about the semi-colon, below. Also, see tcllib's matrix module for a way to manipulate the data as if it were rows and columns. And finally, check out tcllib's report module, which can take matrix objects and generate output from them. Thus, one uses csv to read the data, matrix to store the data, report to print the data, and if you want to change the data, you have either matrix or csv objects that you can work against... Also, if I can suggest, take a look in tcllib's examples/csv directory - Andreas wrote some neat programs that does things like takes csv data and creates HTML tables for output, sorts csv files, cuts csv columns, compares csv files by columns, etc.


Robert Abitbol Indeed! Thanks RS! The concept is very well explained on that page.

Now, the first step (and the most important one!) in this project would be to simply present the CSV file into a sort of file with columns (alt 179) instead of commas.

The algorithm must take into consideration the longest entry in each field and must set the width of that field accordingly.

Note that the program will do that upon entry everytime. After the user has entered data, he will click on Save and Save will represent the file into a CSV file and will save it that way.

Therefore the file is always CSV but the user sees it always with columns.

The user will be able to modify a field by hitting F2 or by clicking on the field with the mouse.

Since the comma is commonly used for text, we'll use the semi-column, to delimit. We'll then have a semi-column delimited file if you will!

Let's try:

This is the file. Name: My library.txt

  Shakespeare, William; Romeo and Juliet; 1767; Theatre
  Puzo, Mario; The Godfather; 1965; Drama
  Verne, Jules; Around the world in 80 days; 1862; Adventure
  Sheldon, Sydney; The other side of midnight; 1967; Mystery
  Mc Cullough, Colleen; Thornbirds; 1967; Saga

jmn *surely* you mean 'semicolon' not 'semi-column'. Sorry to be a wet-blanket - but I think you should leave the data-structure/file-structure design to someone who understands these things. Using semicolons only shifts the problems from text containing commas, to text containing semicolons. You need some other escaping or quoting mechanism. Perhaps you'd be better off just specifying your expected application behaviour rather than making crude attempts to get into the technical details. Unless of course this is an educational exercise for you.. which of course is a valid aim - and what most of this wiki is all about!

Robert Abitbol Semi-colon! Mm! Well like for many English words this is the first time I ever write this word. Thanks for the correction! Hadn't you told me, I would have made the mistake over and over.

Well, I am trying to be as precise as possible. I believe the best would be to put some Rapid File screenshots but I don't seem to have the technology for it!


slebetman: Hmm. Originally you insisted on a comma delimited database so I thought you had a specific, non-technical, reason for using commas. Now you're saying that since you use commas a lot in your data you want to change the delimiter to a semicolon. So it seems like you don't really care what the delimiter is right? As long as the data is stored in a human readable, flat data file?

If so, this is Tcl we're talking about here, why would you want to use an alien data structure? Store your data file as a tcl list! Your code will be simpler since you don't really need to do any parsing of the data whatsoever - let the Tcl interpreter do it for you.

The sample database you've given above, written as a flat Tcl list can be written as follows:

My library.txt:

  {{Shakespeare, William} {Romeo and Juliet} 1767 Theatre}
  {{Puzo, Mario} {The Godfather} 1965 Drama}
  {{Verne, Jules} {Around the world in 80 days} 1862 Adventure}
  {{Sheldon, Sydney} {The other side of midnight} 1967 Mystery}
  {{Mc Cullough, Colleen} Thornbirds 1967 Saga}

The big advantage of this is that "parsing" the database is simply done with:

  set database [read $f]

and saving the database is also simply:

  puts $f $database

Robert Abitbol Very interesting! Your point is very valid: the character used as delimeter is not relevant since the user actually never sees it (unless he looks in the file)!

Next step: I'll try to get a screenshot of how a database could be created in Rapid File. From memory I can say that the user simply did F10 to get to the menu, then (s)he would hit New and then there was a screen to enter the fields types and their names.


Category Database