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
- Next message: LR: "Re: Cross-language challenge (of POSSIBLE interest)"
- Previous message: Sven Axelsson: "Re: Cross-language challenge (of POSSIBLE interest)"
- In reply to: Robert Wagner: "Re: moving data from one place to another in a text file"
- Next in thread: Richard: "Re: moving data from one place to another in a text file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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).
>
- Next message: LR: "Re: Cross-language challenge (of POSSIBLE interest)"
- Previous message: Sven Axelsson: "Re: Cross-language challenge (of POSSIBLE interest)"
- In reply to: Robert Wagner: "Re: moving data from one place to another in a text file"
- Next in thread: Richard: "Re: moving data from one place to another in a text file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|