# Sample code rows = [] with open('train.csv', newline='\n') as csvfile: reader = csv.reader(csvfile, delimiter=',') for row in reader: rows.append(row) X = [] y = [] for i in range(len(rows)): if i==0: # Skip header! continue X.append(row[30].split(" ")) y.append(row[0:30]) # split X and y into train and test set # train a network # load in data from test.csv # generate y_test where y_test is a matrix that is 2049x30 (2049 test images and 30 output features) output = [] header = [] header.append("ImageID.FeatureID") header.append("Value") output.append(header) for i in range(2049): for x in range(30): row = [] row.append(str(i+1)+"."+str(x+1)) # We start Ids at 1, so we need to add 1 to each value row.append(y_test[i][x]) output.append(row) with open('submission.csv', 'w', newline='\n') as f: writer = csv.writer(f) writer.writerows(output)