Skip to content

Instantly share code, notes, and snippets.

@lucidguppy
Created May 22, 2014 00:36
Show Gist options
  • Save lucidguppy/2c8520d8d87aef9b1d02 to your computer and use it in GitHub Desktop.
Save lucidguppy/2c8520d8d87aef9b1d02 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
from csv import reader
letter_template = """
<html>
<body>
<p>{0} {1}</p>
<p>Hi,</p>
<p>It was nice to meet you {0}.</p>
<p>Sincerely,</p>
<p>Mr. Dude</p>
</body>
</html>
"""
with open('names.txt', newline='') as csvfile:
thisreader = reader(csvfile)
for row in thisreader:
first_name = row[0]
second_name = row[1]
letter = letter_template.format(first_name, second_name)
with open('{}{}.html'.format(first_name,second_name), 'w') as fid:
fid.write(letter)
Billy Bartofsky
Mike Karp
Joey Baggadonuts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment