makeHTML.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import csv
  2. import dataset
  3. def readTemplate():
  4. lines1 = ''
  5. with open('uptemplate1.html',encoding='UTF-8') as f:
  6. lines1 = f.readlines()
  7. lines2 = ''
  8. with open('uptemplate2.html',encoding='UTF-8') as f:
  9. lines2 = f.readlines()
  10. lines3 = ''
  11. with open('uptemplate3.html',encoding='UTF-8') as f:
  12. lines3 = f.readlines()
  13. lines4 = ''
  14. with open('uptemplate4.html',encoding='UTF-8') as f:
  15. lines4 = f.readlines()
  16. return lines1,lines2,lines3,lines4
  17. lines1,lines2,lines3,lines4 = readTemplate()
  18. fblines = []
  19. with open('fbReport.csv', newline='',encoding='UTF-8') as csvfile:
  20. rows = csv.reader(csvfile)
  21. for row in rows:
  22. fblines.append('<tr >')
  23. for item in row:
  24. fblines.append('<td>'+item[:15]+'</td>')
  25. #db['ytVideos'].insert({'channelTitle':row[0],'subscribes':row[1],'description':row[2]
  26. #,'videoTitle':row[3],'publishedAt':row[4],'viewCount':row[5],'likeCount':row[6],'favoriteCount':row[7]})
  27. fblines.append('</tr>')
  28. ytlines = []
  29. with open('youtubeReport.csv', newline='',encoding='UTF-8') as csvfile:
  30. rows = csv.reader(csvfile)
  31. for row in rows:
  32. ytlines.append('<tr>')
  33. for item in row[:-1]:
  34. ytlines.append('<td>'+item[:15]+'</td>')
  35. ytlines.append('</tr>')
  36. numPerPage=10*8
  37. numPerPageY=10*9
  38. current_idx = 0
  39. path = 'mix.html'
  40. f = open(path, 'w',encoding='UTF-8')
  41. for i in range(60):
  42. for l in lines1:
  43. f.write(l+'\n')
  44. for idx in range(i*numPerPageY,i*numPerPageY+numPerPageY):
  45. f.write(ytlines[idx]+'\n')
  46. for l in lines2:
  47. f.write(l+'\n')
  48. for idx2 in range(i*numPerPage,i*numPerPage+numPerPage):
  49. f.write(fblines[idx2]+'\n')
  50. for l in lines3:
  51. f.write(l+'\n')
  52. f.write(str(i+6))
  53. for l in lines4:
  54. f.write(l+'\n')
  55. f.close()