-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathprograms (3).py
More file actions
47 lines (30 loc) · 1013 Bytes
/
Copy pathprograms (3).py
File metadata and controls
47 lines (30 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import csv, os
os.chdir(r"C:\Users\Vidyashree M C\PycharmProjects\Alpha4\files\csv_files")
# to read all the names of the employees in employee.csv file
# reader()
with open("employees.csv") as csv_file:
obj = csv.reader(csv_file)
header = next(obj)
# print(header)
# for data in obj:
# print(data[0])
# DictReader()
with open("employees.csv") as csv_file:
obj = csv.DictReader(csv_file)
for data in obj:
print(data)
#################################################################
# Write a program to print only the salaries that are > 70000
# reader()
with open("employees.csv") as csv_file:
obj = csv.reader(csv_file)
header = next(obj)
for data in obj:
if int(data[-1]) > 70000:
print(data[-1])
# DictReader()
with open("employees.csv") as csv_file:
obj = csv.DictReader(csv_file)
for data in obj:
if data["pay"] > "70000":
print(data["pay"])