import csv csv.field_size_limit(1000000000) if __name__ == '__main__': # get md5 to all other properties map md5_to_row = dict() with open("posts-2023-09-14.csv", "r", encoding="utf-8") as input_file: reader = csv.reader(input_file) header = next(reader) for row in reader: # row[3] is md5 this_map = {row[3]:row} md5_to_row.update(this_map) # get all aesthetic ratings aesthetic_score_rows = [] with open("aesthetic_scores_t3.4_q90.csv", "r", ) as input_file_2: reader = csv.reader(input_file_2) _ = next(reader) for row in reader: aesthetic_score_rows.append(row) with open("output.csv", "w", encoding="utf-8", newline="") as output_file: writer = csv.writer(output_file) header.append("aesthetic_score") writer.writerow(header) for row in aesthetic_score_rows: this_md5 = row[1] if this_md5 in md5_to_row.keys(): this_row = md5_to_row[row[1]] this_row.append(row[-1]) writer.writerow(this_row)