ex 2.1 start
This commit is contained in:
parent
4b54d3aba3
commit
8b2d2fb1dd
24
readrides.py
Normal file
24
readrides.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import csv
|
||||||
|
|
||||||
|
|
||||||
|
def read_rides_as_tuples(filename):
|
||||||
|
"""Read the bus ride data as a list of tuples"""
|
||||||
|
records = []
|
||||||
|
with open(filename) as f:
|
||||||
|
rows = csv.reader(f)
|
||||||
|
next(rows)
|
||||||
|
for row in rows:
|
||||||
|
route = row[0]
|
||||||
|
date = row[1]
|
||||||
|
daytype = row[2]
|
||||||
|
rides = int(row[3])
|
||||||
|
record = (route, date, daytype, rides)
|
||||||
|
records.append(record)
|
||||||
|
return records
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import tracemalloc
|
||||||
|
tracemalloc.start()
|
||||||
|
rows = read_rides_as_tuples('Data/ctabus.csv')
|
||||||
|
print('Memory Use: Current %d, Peak %d' % tracemalloc.get_traced_memory())
|
||||||
Loading…
x
Reference in New Issue
Block a user