Re: Text Files or binaries with objects?



On Mon, 6 Mar 2006 08:30:39 +0000 (UTC), "peave" <me@xxxxx> wrote:

Hi.

I have some large text files that I need to repeatedly analyse. I can easily
parse the strings and load the data into my custom object ready to be
analysed, but the parsing has to take time, and I have a large number of
these text files to analyse.

Wouldn't it be more efficient, given that I will be re-analysing each text
file many times over many sessions, to parse the text files once, then save
my list of objects as a binary file, effectively avoiding the need to
repeatedly parse strings? I imagine it would, but I'm not sure how to do it.
At the moment I am using a TStringList to store the custom objects, but it
appears the SaveToFile method only saves the strings, not the objects
associated with them. If I use some SaveToStream cose, how do I decode the
stream when it come back?

The objects I use are really just records at the moment, with several
properties of type 'Single', and one 'TDateTime' property. I have used an
object type just in case I need to add methods etc that I haven't
anticipated.

Perhaps I'm giving you bad advice, but my instinct here is to avoid
complexity.

If you reformat each line of your data so it looks like this as text:-

The text line is here | 31-12-2006, 1234, 1.76, 999 #13#10

Then you can load/save the data as a TStringList

The extra 'parsing' would be pretty insignificant, and you would not
'lose sight' of your data.
.



Relevant Pages

  • Text Files or binaries with objects?
    ... I have some large text files that I need to repeatedly analyse. ... parse the strings and load the data into my custom object ready to be ... file many times over many sessions, to parse the text files once, then save ...
    (alt.comp.lang.borland-delphi)
  • Re: Is it possible to have special characters in list
    ... You *have* to parse that line by line! ... While I agree that one can't treat arbitrary strings as a list, ... way to sensibly handle that list, just because the plaintext-column ... targetted to the problem at hand (parsing that particular format), ...
    (comp.lang.tcl)
  • Re: parsing problem
    ... find the most middle operand and the strings between it -> string1: ... I think that what you really want to get in the end here is a parse ... the only three kinds of nodes in the tree ... static Node ParseAOExpr(string input, ref int index) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: TextboxColumn Nur Zahlen (numerisch)
    ... keine lokalisierten Strings, ... die zwei Fehlermeldungen mehr wird man ja gerade noch hinbekommen. ... Diese kann man nur bei Parse so identifizieren und respektive behandeln. ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • Re: Memory Image, Strings termination
    ... > I am writing a code to analyse a file. ... > file into a memory, then I parse through the content. ...
    (borland.public.delphi.language.objectpascal)