Skip to content

Commit 10d229b

Browse files
reading the data from csv file and printing it to console.
1 parent a45df43 commit 10d229b

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

FileHandling8.py

+12
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,15 @@
1414
w.writerow([eno,ename,esal,eaddr])
1515
print("Total Employee Data inserted into csv file:",f.name)
1616

17+
#Reading employee data from csv file nd print it to console
18+
19+
import csv
20+
with open('emp.csv','r',newline='') as f:
21+
r=csv.reader(f) #returns the reader object pointing to f
22+
data=list(r)
23+
print("Reading data from csv file",f.name)
24+
for line in data:
25+
for word in line:
26+
print(word,'\t',end='')
27+
print()
28+

emp.csv

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ENO,ENAME,ESAL,EADDR
2-
100,Rishabh,50000.0,Pune
3-
101,Vishal,52000.0,Pune
4-
102,Vaibhav,100000.0,Hyderabad
5-
103,Ashu,40000.0,Mumbai
2+
1000,Rishabh,54000.0,Pune
3+
1001,vishal,54692.0,Mumbai
4+
1002,Vaibhav,98542.0,Hyderabad
5+
1003,Ashu,9856.0,Nagpur

0 commit comments

Comments
 (0)