import inout as io files = ['dev-0', 'test-A', 'test-B'] categories = {0: 'news', 1: 'sport', 2: 'opinion', 3: 'business', 4: 'culture', 5: 'lifestyle', 6: 'removed'} if __name__ == '__main__': for file in files: predicted = io.read(file + '/out') predicted = [categories[round(float(x))] for x in predicted] io.write(predicted, file + '/out.tsv')