from os.path import join
from os import walk
from tools.klass_probe import Probe

if __name__ == '__main__':
    #an easy way to treat all files in a tree files
    #for each root folder
    for root, dirs, files in walk('jeux_de_tests'):
        #for each file in files of this root folder
        for file in files:
            #for our example, treatment for only one file
            if file=="A06174testR.csv":
                #create the absolute path
                my_file = join(root, file)
                #create probe
                probe = Probe(my_file)
                #new files and sql db
                csv_cleaned = join('jeux_de_tests','probe.clean.csv')
                probe.clean_and_save(csv_cleaned)
                database_file = join('jeux_de_tests','bdd.sqlite3')
                probe.csv_to_sql(database_file,csv_cleaned)
                #make a test
                print(probe.display_line(10,database_file))