Talk:Reverse the order of lines in a text file while preserving the contents of each line: Difference between revisions

From Rosetta Code
Content added Content deleted
m (added some comments.)
(added some comments about record/line termination.)
Line 26: Line 26:


: I'll attempt to clarify at least one of your points.   It appears, from the   '''Ring'''   computer programming langage example,   that what is meant is to show the lines (records?) in reverse order,   and not change the order of the characters within each line (record).   I will also add a very small "file" so that we can compare output(s) without having to show the input lines(records).     -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 15:16, 3 August 2021 (UTC)
: I'll attempt to clarify at least one of your points.   It appears, from the   '''Ring'''   computer programming langage example,   that what is meant is to show the lines (records?) in reverse order,   and not change the order of the characters within each line (record).   I will also add a very small "file" so that we can compare output(s) without having to show the input lines(records).     -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 15:16, 3 August 2021 (UTC)

: This might not be the proper forum or time to address the issue of line/record termination,   but not all operating systems terminate a line (or record) with any specific character (or characters).   That information may be contained in a meta structure,   which (may) contain the block length, record length, and type of blocking (if there is blocking), among other information.   It is (or can be) the purpose of the computer programming language (or operating system) to examine the operating system and/or file structure to determine how to read/write lines/records and how they're delineated (if at all).     -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 16:18, 3 August 2021 (UTC)

Revision as of 16:18, 3 August 2021

Incredibly vague task

Once again, the master of vagarity has struck. Some details need to be hammered out for this to be a task.

  • What is a line?
    • Is it a record that ends with a 0xD character?
    • a 0xA character?
    • a 0xA 0xD digraph?
    • Is there a particular encoding that can be assumed? (ASCII?, EBCDIC?, ISO-Latin-1?, UTF8?)
    • How about binary files?
  • What is to be reversed?
    • Each record in the file?
    • The order of records in a file?
    • Both?
    • What about binary files?
  • What restrictions are there on holding the file in memory?
    • Can it be read in all at once?
    • Does it need to be processed a record at a time?
    • Does it need to be read in starting from the end of the file, proceeding to the beginning?
      • If so, should it be processed in non-record sized blocks?
      • Or a byte / character at a time? (Which circles back around to encoding.)

Every single one of these questions will change the way the program must be written. --Thundergnat (talk) 14:34, 3 August 2021 (UTC)


I'll attempt to clarify at least one of your points.   It appears, from the   Ring   computer programming langage example,   that what is meant is to show the lines (records?) in reverse order,   and not change the order of the characters within each line (record).   I will also add a very small "file" so that we can compare output(s) without having to show the input lines(records).     -- Gerard Schildberger (talk) 15:16, 3 August 2021 (UTC)
This might not be the proper forum or time to address the issue of line/record termination,   but not all operating systems terminate a line (or record) with any specific character (or characters).   That information may be contained in a meta structure,   which (may) contain the block length, record length, and type of blocking (if there is blocking), among other information.   It is (or can be) the purpose of the computer programming language (or operating system) to examine the operating system and/or file structure to determine how to read/write lines/records and how they're delineated (if at all).     -- Gerard Schildberger (talk) 16:18, 3 August 2021 (UTC)