Replacing a report only after validation

An engineering analysis script reads measurements.txt and produces report.txt, which already contains a previous valid report. The requirements are:

  • A successful run replaces the entire previous report with a new header and mean force.
  • If any input record is malformed, the previous report remains unchanged.
  • An input containing no accepted measurements is invalid.

The input fits in memory. Assume no filesystem errors occur, and the two filenames identify different files. Which sequence satisfies all three requirements?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Text File Operations Questions: