I was able to generate html file per row.
my current output for "text_file 1.html" is the header: ['ID', 'Name', 'Type', '3 Year Funds Offered', '3 Year Funds Sold', 'Est. Most Recent Fund Date', 'Investor Location', 'Investor City', 'Investor State', 'Investor Country', 'Portfolio Size', 'Number of Deals', 'Website', 'Average Growth Score']
But I want to customize the table/data and keep the Header for each data from csv.
Here's my sample code:
import csv
with open('test.csv', 'r') as csvfile:
r = csv.reader(csvfile, delimiter=',')
cnt=0
for row in r:
cnt+=1
file_path="text_file %s.html" % (str(cnt),)
with open(file_path,"w") as text_file:
text_file.write(str(row)+"\n")`enter code here`
Do you have any tips so I can run this correctly? Thanks!
my_headers = ['ID', 'Name', 'Type', '3 Year Funds Offered', '3 Year Funds Sold',...]beforewith open('test.csv', 'r') as csvfile:and then underwith open(file_path,"w") as text_file:have another line that writes your headers liketext_file.write(','.join(item for item in my_headers)+"\n"). And then look atpandas to_htmland use that instead :)