729 B
729 B
Exercise 8.2 - Solution
# ticker.py
from structure import Structure
class Ticker(Structure):
= String()
name = Float()
price = String()
date = String()
time = Float()
change open = Float()
= Float()
high = Float()
low = Integer()
volume
if __name__ == '__main__':
from follow import follow
import csv
from tableformat import create_formatter, print_table
= create_formatter('text')
formatter
= follow('Data/stocklog.csv')
lines = csv.reader(lines)
rows = (Ticker.from_row(row) for row in rows)
records = (rec for rec in records if rec.change < 0)
negative 'name','price','change'], formatter) print_table(negative, [