Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a python program that opens a csv data file (sampledata.csv) and reads int

ID: 3775461 • Letter: W

Question

Write a python program that opens a csv data file (sampledata.csv) and reads into a list. Then it writes to an HTML page. The program should read data from the input file and merge it into HTML statements, into an output file. The hardcoded data in the html file (sampletags.html) should be replace with the data from the file. Use a loop to write out the divs in the HTML file. Name the output file sampleoutput.html.

Here are the fields in the order the appear in a row of data in the file:

date_of_registration
title
firstname
lastname
address1
address2
city
state
zipcode
telephone
email
website
position
company
meals
billing_firstname
billing_lastname
card_type
card_number
card_csv
exp_year
exp_month
session1
session2
session3

sampledata.csv

sampletags.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

</head>
<body>
<main>
<div class="wrap">
<div class="row1">
<div class="tag">
<div class="firstName">Jack</div>
<div class="lastName">Smith</div>
<div class="title">Sales</div>
<div class="company">Sales Inc.</div>
<div class="address">Salinas, CA</div>
</div>
<div class="tag">
<div class="firstName">Jack</div>
<div class="lastName">Smith</div>
<div class="title">Sales</div>
<div class="company">Sales Inc.</div>
<div class="address">Salinas, CA</div>
</div>
<div class="tag">
<div class="firstName">Jack</div>
<div class="lastName">Smith</div>
<div class="title">Sales</div>
<div class="company">Sales Inc.</div>
<div class="address">Salinas, CA</div>
</div>
</div>
</main>
</body>
</html>

######## Mr. Benjamin3 Reyes 434 Rodeo Dr. Austin TX 45678 303-111-2222 benreyes@fake.com http://www.google.edu Quality Control Lead Quality Is Us! mealpack Benjamin3 Reyes V 3.46E+15 5476 2019 4 Workshop A Workshop D Workshop H ######## Mr. Bill3 Gates 123 Microsoft Dr. Redmond WA 80333 303-444-5555 bill@fake.com http://www.google.edu Computer Programmer Microsoft mealpack Bill3 Gates MC 9.88E+15 5232 2017 9 Workshop A Workshop D Workshop I ######## Ms. Corrinne3 Yu 123 Microsoft Dr. Santa Monica CA 12345 303-555-6666 corrine@fake.com http://www.google.edu Game Programmer Naughty Dog dinnerday2 Corrinne3 Yu AE 6.54E+15 2745 2018 12 Workshop B Workshop I

Explanation / Answer

import csv
list=[]
with open('sampledata.csv', 'rb') as f:
reader = csv.reader(f)
for row in reader:
       list1=[]
       for i in row:
           list1.append(i)
       list.append(list1)  

f = open('sampletags.html', 'r')
g= open('sampleoutput.html', 'r')
#sampleoutput.html
f.write("""<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<main>
<div class="wrap">""")
count=1
for i in list:
   f.write("<div"row"="+str(count)+">")
   for j in i:
       f.write("<div class=/"tag/">")
       f.write("div"+str(j)+"</div>")
       f.write("</div>")
   f.write("</div>")
   count=count+1
f.write("""</div>
</main>
</body>
</html>""")  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote