
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('<tr style="display: none;">')
        for item in row:
            dataLines.append('<td>'+item[:15]+'</td>')
        #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('</tr>')


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()
'''
<tr style="display: none;">
                        <td>10</td>
                        <td>Table cell</td>
                        <td>Table cell</td>
                        <td>Table cell</td>
                        <td>Table cell</td>
                        <td>Table cell</td>
                        <td>Table cell</td>
                      </tr>
'''