Simran Khanuja commited on
Commit
1c901ff
1 Parent(s): c2d9c79

removing script

Browse files
Files changed (1) hide show
  1. json_to_csv.py +0 -41
json_to_csv.py DELETED
@@ -1,41 +0,0 @@
1
- import json
2
- import csv
3
-
4
- # Read JSON data
5
- with open('/Users/simrankhanuja/Desktop/zeno-winoground/dataTagsSep4.json', 'r') as json_file:
6
- data = json.load(json_file)
7
-
8
- # Process and write to CSV
9
- with open('output.csv', 'w', newline='') as csv_file:
10
- writer = csv.writer(csv_file)
11
-
12
- # Write header
13
- header = ["id", "image", "caption",
14
- "Old Tags: id", "Old Tags: tag", "Old Tags: secondary tag",
15
- "Old Tags: num_main_preds", "Old Tags: collapsed tag",
16
- "Our Tags: Attribute", "Our Tags: Relation", "Our Tags: Reasoning", "Why is WG hard"]
17
- writer.writerow(header)
18
-
19
- for entry in data:
20
- for idx in range(2): # As there are two images/captions per entry
21
- row = []
22
- row.append(f"{entry['id']}_{idx}")
23
- row.append(entry[f'image_{idx}'])
24
- row.append(entry[f'caption_{idx}'])
25
-
26
- old_tags = entry["Old Tags"]
27
- row.extend([old_tags['id'],
28
- old_tags['tag'],
29
- old_tags['secondary_tag'],
30
- old_tags['num_main_preds'],
31
- old_tags['collapsed_tag']])
32
-
33
- our_tags = entry["Our Tags"]
34
- attribute = our_tags.get('Attribute', [])
35
- relation = our_tags.get('Relation', [])
36
- reasoning = our_tags.get('Reasoning', [])
37
-
38
- row.extend([attribute, relation, reasoning])
39
-
40
- row.append(entry["Why is WG hard"])
41
- writer.writerow(row)