15 lines
No EOL
452 B
Python
15 lines
No EOL
452 B
Python
def read_csv_lazy(filename):
|
|
try:
|
|
with open(filename) as file:
|
|
line_number = 0
|
|
for line in file:
|
|
if line_number == 0:
|
|
line_number =1
|
|
continue
|
|
values = line.strip().split(",")
|
|
yield {"name":values[0], "age":values[1], "city":values[2]}
|
|
except:
|
|
print("File not found")
|
|
|
|
for row in read_csv_lazy("/Users/v1ptyoz/learn/Python/Task 6/data.csv"):
|
|
print(f"{row['name']} is {row['age']}") |