Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider a file named rainfall.txt that contains records of rainfall. Each line in the file contains the name of a place, a date and the

Consider a file named rainfall.txt that contains records of rainfall. Each line in the file contains the name of a place, a date and the recorded rainfall in mm. Given below is a sample content of this file:
Gordons Bay,2019/03/01,12
Johannesburg,2019/01/30,25
Hammanskral,2019/04/12,7
Mamelodi,2019/06/23,1
Port Elizabeth,2019/10/19,3
(a) State the format of the data in this file. (2 marks)
(b) Which function can be used to open the file rainfall.txt for reading only? (2 marks)
(c) Which function can be used to open the file rainfall.txt for writing data at the end of the file without deleting the existing content? (2 marks)
(d) Assume that the file was successfully opened for reading. Which function can be used to read a line in the file and return an array of three substrings by splitting this line? (3 marks)
(e) Write code to copy the contents of rainfall.txt to rainfall_new.txt.(2 marks)
(f) Write code to rename the file rainfall.txt to rainfall_old.txt.(2 marks)
(g) Write code to delete the file rainfall_old.txt.(2 marks)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data With Hadoop MapReduce A Classroom Approach

Authors: Rathinaraja Jeyaraj ,Ganeshkumar Pugalendhi ,Anand Paul

1st Edition

1774634848, 978-1774634844

More Books

Students also viewed these Databases questions