我能够每行生成html文件。
“text_file 1.html”的当前输出是标题:['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']
但我想自定义表/数据并保留csv中每个数据的标题。
这是我的示例代码:
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`
您有任何提示,以便我可以正确运行吗?谢谢!