import csv import dataset def readTemplate(): upper_lines = '' with open('youtubeTable_upper.html',encoding='UTF-8') as f: upper_lines = f.readlines() lower_lines = '' with open('youtubeTable_lower.html',encoding='UTF-8') as f: lower_lines = f.readlines() return upper_lines, lower_lines upper_lines, lower_lines = readTemplate() dataLines = [] with open('youtubeReport.csv', newline='',encoding='UTF-8') as csvfile: rows = csv.reader(csvfile) for row in rows: dataLines.append('') for item in row: dataLines.append(''+item[:15]+'') #db['ytVideos'].insert({'channelTitle':row[0],'subscribes':row[1],'description':row[2] #,'videoTitle':row[3],'publishedAt':row[4],'viewCount':row[5],'likeCount':row[6],'favoriteCount':row[7]}) dataLines.append('') path = 'youtueTemplate.html' f = open(path, 'w',encoding='UTF-8') for l in upper_lines: f.write(l+'\n') for l in dataLines: f.write(l+'\n') for l in lower_lines: f.write(l+'\n') f.close() ''' 10 Table cell Table cell Table cell Table cell Table cell Table cell '''