Re: Data table text I/O package?




On 16 Jun 2005, at 10:55, Jacob Sparre Andersen wrote:

Randy Brukardt wrote:

I may be dense, but isn't this the purpose of XML? If so, why
reinvent the wheel?

d) I'm _not_ going to switch away from tabulator separated tables for purposes, where tabulator separated tables are a sensible representation of the data in textual form.

Indeed. XML is for semi-structured data and/or text data with Unicode etc. For tables of atomic data tab separated is better. More readable, efficient, sensible, not requiring a monster XML library.


It is the matter of
automagically generating code for reading and writing that file
format.

Yes. This is interesting, useful, and easy. From the header you get the field names, from the first data line with deduce the data types. With these elements you can generate the record type and procedures to read the file. A trick I often use to deduce data types is based on 'Value:


function Get_Type (Value : String) return Data_Type is
   F : Float;
   I : Integer;
begin
   F := Float'Value (Value);
   return Type_Float;
exception
   when Constraint_Error =>
      begin
         I := Integer'Value (Value);
         return Type_Integer;
      exception
         when Constraint_Error =>
            return Type_String;
      end;
end;

.