131k views
3 votes
Suppose that a file named sensor.dat contains information collected from a set of sensors. Each row contains a set of sensor readings, with the first row containing values collected at 0 seconds, the second row containing values collected at 1.0 sec-onds, and so on.11.Write a program to read the data file and print the number of sensors and the number of seconds of data contained in the file. (Hint: use the sizefunction.)

User Sterlin
by
4.9k points

1 Answer

4 votes

Answer:

The program in Python is as follows:

myfile = open("sensor.dat", "r")

for line in myfile:

print(line)

myfile.close()

Step-by-step explanation:

This opens the file for read operation

myfile = open("sensor.dat", "r")

This iterates through the file

for line in myfile:

Print record on each row

print(line)

Close file

myfile.close()

User Benterris
by
5.4k points