Talk:Reverse the order of lines in a text file while preserving the contents of each line
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)