Use dict to handle quotes (ref #9)
This commit is contained in:
parent
9b1a45d3cc
commit
85f457fc20
2 changed files with 4 additions and 4 deletions
|
@ -49,14 +49,13 @@ for root, dirs, files in os.walk('quotes/'):
|
|||
if ext == '.csv':
|
||||
full_name = os.path.join(root, name)
|
||||
with open(full_name) as csvfile:
|
||||
csvreader = csv.reader(csvfile, delimiter=',', quotechar='`', skipinitialspace=True)
|
||||
csvreader = csv.DictReader(csvfile, delimiter=',', quotechar='`', skipinitialspace=True)
|
||||
quotes += list(csvreader)
|
||||
|
||||
print('Found %d total quotes' % len(quotes))
|
||||
print(f"Found {len(quotes)} total quotes")
|
||||
|
||||
row = random.choice(quotes)
|
||||
|
||||
text = '<p>{}</p> - {}, <a href={}>{}</a>'.format(row[0], row[1], row[2], row[3])
|
||||
text = f"<p>{row['quote']}</p> - {row['author']}, <a href={row['link']}>{row['linktitle']}</a>"
|
||||
print(text)
|
||||
|
||||
if not args.debug:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
quote,author,link,linktitle
|
||||
`Workers of the World, Unite!`,`Karl Marx and Frederick Engels`,`http://marxists.org/archive/marx/works/1848/communist-manifesto/ch04.htm#210`,`Communist Manifesto (1848)`
|
||||
`If we have chosen the position in life in which we can most of all work for mankind, no burdens can bow us down, because they are sacrifices for the benefit of all; then we shall experience no petty, limited, selfish joy, but our happiness will belong to millions, our deeds will live on quietly but perpetually at work, and over our ashes will be shed the hot tears of noble people.`,`Karl Marx`,`http://marxists.org/archive/marx/works/1837-pre/letters/37_11_10.htm`,`Letter to His Father (1837)`
|
||||
`History calls those men the greatest who have ennobled themselves by working for the common good; experience acclaims as happiest the man who has made the greatest number of people happy.`,`Karl Marx`,`http://marxists.org/archive/marx/works/1837-pre/letters/37_11_10.htm`,`Letter to His Father (1837)`
|
||||
|
|
|
Loading…
Reference in a new issue