Xref: utzoo comp.os.vms:8953 comp.unix.wizards:11342 comp.lang.misc:1924 Path: utzoo!utgpu!water!watmath!clyde!att!pacbell!ames!mailrus!cornell!batcomputer!itsgw!steinmetz!uunet!mcvax!enea!sommar From: sommar@enea.se (Erland Sommarskog) Newsgroups: comp.os.vms,comp.unix.wizards,comp.lang.misc Subject: Text or data files? Message-ID: <3958@enea.se> Date: 25 Sep 88 18:17:33 GMT Followup-To: comp.lang.misc Organization: ENEA DATA AB, Sweden Lines: 52 (This stems from the discussions of VMS and Unix file systems. I've added comp.lang.misc and directed follow-ups there. It doesn't belong to comp.os.vms anymore and I don't read comp.unix.wizards.) Miles O'Neal (meo@stiatl.UUCP) writes: >If you even have your data files as text files, debugging >becomes much easier. For instance, would you rather debug >98764389437034gh307ytfhr398f39 >or >12/22/88 01:30 10790 100 100 382 -1 >? >These are not real data, but examples of what data files I've dealt >with looked like. The processing to do all this is cheap nowdays, >so why not use text files if there is no OVERWHELMING reason not to? There are several advantages of using fixed record files for data, if the data I have fits to that format. Let's say we have: (This is Pascal.) Data_record = RECORD Date : PACKED ARRAY(.1..8.) OF char; Time : PACKED ARRAY(.1..8.) OF char; Incident : Incident_type; (* Enumerated *) No_of_warnings : integer; Alarmed : boolan; Username : PACKED ARRAY(.1..12.) OF char; END; The simplest way to read and write this is to through a FILE OF Data_record, if no other programs is to read it. If we store the data in a text file, we have to parse every line we get. (And what a trouble if Username contains an LF character.) And since the text file is vulnerable to changes from e.g. a text editor, we cannot be sure that the file follows the supposed format throughout. As for debugging this only applies if you have to look at the file as such. >Another thing this buys you is that, in my experience, its easier >to change file formats if you use text files. It requires a little >plannning, but in general is a lot less work than doing the same >thing with any other type of data. Uh? If you have a text file and change the format you have to rewrite the parsing and the writing-to file parts. With a fixed format you change the declaration, and that's all. (Well, you may have to write a simple program to convert old files, but you have do to that for text files too.) -- Erland Sommarskog ! "Hon ligger med min b{ste v{n, ENEA Data, Stockholm ! jag v}gar inte sova l{ngre", Orup sommar@enea.UUCP ! ("She's making love with best friend, ! I dare not to sleep anymore")