diff --git a/templates/main.py b/templates/main.py index c12c8b4..a4a1b8d 100644 --- a/templates/main.py +++ b/templates/main.py @@ -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 = '

{}

    - {}, {}'.format(row[0], row[1], row[2], row[3]) +text = f"

{row['quote']}

    - {row['author']}, {row['linktitle']}" print(text) if not args.debug: diff --git a/templates/quotes/marxistquotes.csv b/templates/quotes/marxistquotes.csv index 9ef797b..b33b9cf 100644 --- a/templates/quotes/marxistquotes.csv +++ b/templates/quotes/marxistquotes.csv @@ -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)`