fNumCores ='NCore.txt'
fMemSize ='MSize.txt'
fPartition ='partition_format.txt'
fOut = 'TSPartiConfig.txt'

"""
create config file required to partition time series. It's assumed that partition.txt file is
already formatted to be a tab seperated file
"""

fdNumCores = open(fNumCores, 'r')
fdMemSize = open(fMemSize, 'r')
fdPartition = open(fPartition, 'r')
fdOut = open(fOut, 'w')

line = fdNumCores.readline()
num_cores = line.split()
line = fdMemSize.readline()
mem_size = line.split()
partition = []
for line in fdPartition:
    partition.append(line.split())

for i in range(0, len(num_cores)):
    tmp_str = str(i) + '\t' + num_cores[i] + '\t' + mem_size[i] 
    for j in range(0, len(partition[i])): tmp_str = tmp_str + '\t' + partition[i][j]
    fdOut.write(tmp_str + '\n')
fdOut.close()
fdNumCores.close()
fdMemSize.close()
fdPartition.close()
