read entire content of a file using infile python

Solutions on MaxInterview for read entire content of a file using infile python by the best coders in the world

showing results for - "read entire content of a file using infile python"
Nicolò
11 Mar 2017
1#Create a variable for the file name
2filename = 'Plates_output_simple.csv' #This is simply a string of text
3
4#Open the file
5infile = open(filename, 'r') # 'r' says we are opening the file to read, infile is the opened file object that we will read from
6
7#Store the data from the file in a variable
8data = infile.read()
9
10#Print the data in the file
11print(data)
12
13#close the file
14infile.close()
15