Re: moving data from one place to another in a text file

From: William M. Klein (wmklein_at_nospam.netcom.com)
Date: 02/24/05


Date: Thu, 24 Feb 2005 14:05:55 GMT

Personally, I would say that the "read twice" solution is the ONLY truly
practical solution - as any solution requiring "memory allocation" canNOT handle
potentially "available memory-size + 1" sized file input - while the read twice
method can.

And, of course, the "read twice method" would be portable to EVERY ANSI/ISO
conforming compiler from the '68 Standard on.

As with the cross-language challenge, if a "real world" solution were required
to be the "fastest" possible *AND* the size of the input file were smaller than
the "probable" available memory, then an "in memory solution" could be created
(but that could also use an ANSI/ISO Standard table - or an ANSI/ISO Standard
SORT - or any of a number of "practical" and PORTABLE solutions)

-- 
Bill Klein
 wmklein <at> ix.netcom.com
"Robert Wagner" <spamblocker-robert@wagner.net> wrote in message 
news:375r11l7lpdk0v9rl93l1sv2pmnv3pithf@4ax.com...
> On Thu, 24 Feb 2005 03:18:05 GMT, "William M. Klein"
> <wmklein@nospam.netcom.com> wrote:
>
>>"Robert Wagner" <spamblocker-robert@wagner.net> wrote in message
>>news:2dbq1198emt1p5r3827lfgskmhl90m1bn3@4ax.com...
>>> On Wed, 23 Feb 2005 08:36:31 -0800, "Chuck Stevens"
>>> <charles.stevens@unisys.com> wrote:
>>>
>><snip>
>>> If you have a PRACTICAL solution that works on more than the three
>>> best-selling compilers, I'm listening.
>>
>>The original text of this thread's message was,
>>
>>"I have a COBOL file that reads an entire text file and gives as an
>>output the same input file with another name. The problem is that in
>>the input file the last two lines (that contain numerical values only)
>>must be located some place else in the output file. How can I achieve
>>this ?
>>
>>Thank you
>>
>>Francesco"
>>
>>Clearly, that can't be what you are claiming cannot be done in a Standard 
>>('85,
>>'02 - or even '68 or '74) manner.  As people have changed the "topic" so much
>>without changing the subject, can you tell me what you are asking for a 
>>(truly)
>>generalized solution for?
>
> I was referring to the general problem of lists. Given that two lines
> need to be moved, they can be stored in a two entry array and the
> input file read twice. A general version of the problem would call for
> moving m lines, where m can be zero thru the file size (n). An example
> is sorting the file. Sorting could be done with a two entry array, but
> the result would, on average, require copying n^2 records (assuming
> one input and output file per pass).
> 


Relevant Pages

  • Re: NEWBIE - Create array variables depending upon input file
    ... > Ie in my data file I have a time when a car enters my study area, ... everything is turned into bits and bytes in memory. ... lines in your input file, ...
    (alt.comp.lang.learn.c-cpp)
  • Re: SLOW typing response time using Mac Office 2008
    ... Anything running on a PPC needs twice the memory of something running on ... Which occupies twice the memory. ... and noticed a marked improvement in the response time, ... But I usually have Safari 3.0.4 running in the background, ...
    (microsoft.public.mac.office.word)
  • Reasons For 64-bit: A Digest
    ... First of all, you are of course, absolutely right about your observation that a 64-bit Pointer is twice the size of a 32-bit pointer. ... I really wish the "64-bit Lobby" had made a digest of our arguments while we were fighting to get a native 64-bit compiler on the Road Map.. ... twice as many registers: double the number of general purpose registers and double the number of XMM registers. ... Expanded address space so instead of being limited to 4 GB of memory you're limited to terabytes of memory. ...
    (borland.public.delphi.non-technical)
  • Re: WWDC -- MacBook Pro?
    ... twice as big. ... consume extra memory and cache ... cache causing more cache invalidates, and a when a cache line is ... As this program rewriting happens, the 32-bit computers will die away from ...
    (comp.sys.mac.system)
  • Re: Delete a line
    ... - read next record from input fileinto memory ... awk will not by itself modify an input file in place. ... keeps the results in an array in memory; ... This will fail if the amount of data doesn't fit in memory, ...
    (comp.lang.awk)