import pandas as pd
import os
import glob

read_path = os.getcwd()
# print(read_path)

read_files = glob.glob(read_path+"/kyouzai*.csv")
read_video = glob.glob(read_path+"/video_*.csv")
# print(len(read_files))
# print(len(read_video))

dir_path = 'kyouzai'

#HP用
cols = ["HPtitle", "HPurl", "Hpnumber", "student", "evaluation", "text", "date"]
dd =pd.DataFrame(columns = cols)

colls = ["HPtitle", "HPurl", "Hpnumber", "student", "evaluation", "text", "date", "Credibility_score", " Score_average"]
ddd =pd.DataFrame(columns = cols)

#YouTube用
col = ["Youtubetitel", "Youtubeurl", "Youtubenumber","student","evaluation", "text","date","Youtubeid"]
ee = pd.DataFrame(columns = col)

co = ["Youtubetitel", "Youtubeurl", "Youtubenumber","student", "evaluation", "text","date","Credibility_score","Ave_score"]
eee = pd.DataFrame(columns = co)


for i in range(len(read_files)):
    os.makedirs(dir_path+str(i), exist_ok = True)
    read_file = read_files[i]
    read_videos = read_video[i]
    df = pd.read_csv(read_file, encoding='utf-8')
    dff = pd.read_csv(read_videos, encoding="utf-8")
    length = len(df)
    lengths = len(dff)
    list=[]
    lists=[]
    for j in range(len(df)):
        list.append(j)

    for j in range(len(dff)):
        lists.append(j)
    # print(read_file)

    df['Hpnumber'] = list
    df['Credibility_score'] = ''

    dff.insert(2,"Youtubenumber",lists)
    dff['Credibility_score'] = ''

    df.to_csv("kyouzai"+str(i)+"/kyouzaiDB.csv", index=None, encoding="cp932",errors='ignore')
    dd.to_csv("kyouzai"+str(i)+"/review_prac.csv", index=None, encoding="cp932",errors='ignore')
    ddd.to_csv("kyouzai"+str(i)+"/review_score.csv", index=None, encoding="cp932",errors='ignore')
    
    dff.to_csv("kyouzai"+str(i)+"/video_kyouzai.csv", index=None, encoding="cp932",errors='ignore')
    ee.to_csv("kyouzai"+str(i)+"/video_Review.csv", index=None, encoding="cp932",errors='ignore')
    eee.to_csv("kyouzai"+str(i)+"/video_score.csv", index=None, encoding="cp932",errors='ignore')



    