import pandas as pd
import os

from utils.cluster import cluster_data,plot_clusters_figure
from utils.myfile import test_function

#Read data 
dataTXT = pd.read_csv("08dd04b9-0eb9-4d94-8bbb-a143504274f9/datafile.csv")
dataCSV = pd.read_csv("08dd1396-bec3-4732-81a4-04afd19df6e0/datafile.csv")
data = pd.concat([dataTXT, dataCSV], axis=0, ignore_index=True)

result = test_function()
print(result)
#Code to run
#Add here the code to run. You can create different functions and the results should be clear stated.
clustered_data, reduced_clustered_data, cluster_centers = cluster_data(data=data)
clusters_figure = plot_clusters_figure(data=reduced_clustered_data, centroids=cluster_centers)

#Gather results
#The results variable should be a list of dicts. Each dict element must have the following elements:
# "data": the results, "name": name of the results (will be used a the filename in which this resuls will be stored),
# and "format": the format in which you want to store the results (fig, csv, txt for the moment)

filename="results/demofile2.txt"
os.makedirs(os.path.dirname(filename), exist_ok=True)
f = open(filename, "w")
f.write("clustered_data: " + str(clustered_data) + "\n")
f.close()

clusters_figure.savefig('/results/figure.fig')