I have two files, one is text file and the other is a csv file. The text file has a string format like this
To: {email}
From: [email protected]
Subject: Deals!
Hi {first_name},
I want to replace email
and first_name
with some data I have in the csv file.
I write this code, but I couldn't replace the values
import csv
with open ("emails.csv","r")as csvfile:
rows = csv.reader(csvfile)
with open ("email_template.txt","r", encoding="utf8") as efile:
my_string = efile.read()
my_string =''.join(i for i in my_string).replace("email","555")
print(my_string)
for row in rows:
print (row[0]+ " " +str(row[2]))