-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
28 lines (25 loc) · 918 Bytes
/
main.py
File metadata and controls
28 lines (25 loc) · 918 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
from hashtable_open_addressing import HashTable
import csv
if __name__ == "__main__":
ht = HashTable(30)
"""
1. Extract the records from the student_data file
and add them one at a time, as a Python dict,
containing the name, class and their associated
data as key-value dict pairs, to the hashtable
2. You can use the id as the hash table key for
each of the above records.
"""
# Test your hashtable using appropriate methods
# from your implementation
with open('student_data.csv', 'r') as f:
reader = csv.DictReader(f)
for row in reader:
ht.setitem(row['id'], (row['name'], row['class']))
print(ht.getitem(row['id']))
#f.close is called automatically
print(ht.getitem('s0002b'))
print(ht.getitem('s0053c'))
print(ht.getitem('fsdaaufd'))
ht.del_item('s0053c')
print(ht.getitem('s0053c'))