File size: 1,133 Bytes
6c31714 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
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)
|