-
Notifications
You must be signed in to change notification settings - Fork 3
/
csv2html_script.py
24 lines (20 loc) · 976 Bytes
/
csv2html_script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import csv
if __name__ == "__main__":
message = ""
with open("df_sorted_no_dups.csv", "r") as csv_file:
reader = csv.DictReader(csv_file)
i = 1
for row in reader:
temp = str(i)+ "<p><b> </b><b>Name -</b> {name}, <b>Rating -</b> {rating}, <b>No. of Reviews -</b> {no_of_reviews}, <b>Popularity -</b> {popularity}</p>".format(
name=row["name"],
rating=row["rating"],
no_of_reviews=row["no_of_reviews"],
popularity=row["popularity"]
)
temp += '<img src="{source}"/>'.format(source=row["img_links"])
temp = "<div>" + temp + "</div>"
message += temp
i+=1
message = "<html><body><style> div { margin: 5px } img { width : 200px; height: 200px; }</style>" + message + "</body></html>"
with open("output.html", "w") as output_file:
output_file.write(message)