How to Read Data from CSV File in Python
Master Python with 70+ Hands-on Projects and Get Job-ready - Learn Python
Program 1
# how to read data from CSV File
import csv,os,sys
try:
if(os.path.isfile("c://myfile/emp.csv")):
f=open("c://myfile/emp.csv","r")
obj=csv.reader(f)
mylist=list(obj)
for row in mylist:
for col in row:
print(col,end=" ")
print()
else:
print("File Not Found......")
except Exception as obj:
print(obj)
Did you like this article? If Yes, please give DataFlair 5 Stars on Google

