import csv import dataset def readTemplate(): lines1 = '' with open('uptemplate1.html',encoding='UTF-8') as f: lines1 = f.readlines() lines2 = '' with open('uptemplate2.html',encoding='UTF-8') as f: lines2 = f.readlines() lines3 = '' with open('uptemplate3.html',encoding='UTF-8') as f: lines3 = f.readlines() lines4 = '' with open('uptemplate4.html',encoding='UTF-8') as f: lines4 = f.readlines() return lines1,lines2,lines3,lines4 lines1,lines2,lines3,lines4 = readTemplate() fblines = [] with open('fbReport.csv', newline='',encoding='UTF-8') as csvfile: rows = csv.reader(csvfile) for row in rows: fblines.append('') for item in row: fblines.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]}) fblines.append('') ytlines = [] with open('youtubeReport.csv', newline='',encoding='UTF-8') as csvfile: rows = csv.reader(csvfile) for row in rows: ytlines.append('') for item in row[:-1]: ytlines.append(''+item[:15]+'') ytlines.append('') numPerPage=10*8 numPerPageY=10*9 current_idx = 0 path = 'mix.html' f = open(path, 'w',encoding='UTF-8') for i in range(60): for l in lines1: f.write(l+'\n') for idx in range(i*numPerPageY,i*numPerPageY+numPerPageY): f.write(ytlines[idx]+'\n') for l in lines2: f.write(l+'\n') for idx2 in range(i*numPerPage,i*numPerPage+numPerPage): f.write(fblines[idx2]+'\n') for l in lines3: f.write(l+'\n') f.write(str(i+6)) for l in lines4: f.write(l+'\n') f.close()