Changeset 34438
- Timestamp:
- 2020-10-04T23:47:43+13:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/model-sites-dev/mars/collect/deam/MERGE-CSV-FEATURES-AND-AV-FILES.py
r34436 r34438 5 5 from collections import OrderedDict 6 6 7 # result = OrderedDict()8 9 7 def csv_features_to_dict(csv_filename): 10 # csv_features_file = open('etc/deam-essentia-features-collated.csv')11 8 csv_features_file = open(csv_filename) 12 9 csv_features_reader = csv.reader(csv_features_file, delimiter=',', quotechar='"') … … 21 18 row.pop(0) 22 19 header_row = row 23 # print(f'Column names are {", ".join(row)}')24 20 else: 25 21 full_file_id = row[0] … … 47 43 48 44 csv_file = open(csv_filename) 49 csv_reader = csv.reader(csv_f eatures_file, delimiter=',')45 csv_reader = csv.reader(csv_file, delimiter=',') 50 46 51 47 csv_gt_dict = {} … … 56 52 for row in csv_reader: 57 53 if line_count == 0: 54 row.pop(0) 58 55 header_row = row 59 # print(f'Column names are {", ".join(row)}')60 56 else: 61 song_id = row[0] 57 song_id = int(row[0]) 58 row.pop(0) 62 59 63 # print(f'\tsong-id: {song_id}') 64 csv_gt_dict[song_id] = row 60 row_ordered_dict = OrderedDict() 61 62 for i in range(0, len(row)): 63 field = header_row[i]; 64 value = row[i]; 65 66 row_ordered_dict[field] = value 67 68 csv_gt_dict[song_id] = row_ordered_dict 65 69 66 70 line_count += 1 … … 71 75 csv_features_dict = csv_features_to_dict('etc/deam-essentia-features-collated.csv') 72 76 73 #for song_id_key in csv_features_dict: 74 # print(song_id_key + "\n" + str(csv_features_dict[song_id_key])) 77 print("Essentia Features (sample of first 3 ids):") 78 i = 1 79 for song_id_key, ordered_feature_vals in sorted(csv_features_dict.items()): 80 # print(str(song_id_key) + "\n" + str(ordered_feature_vals)) 81 if i >= 3: 82 break 83 i = i + 1 75 84 76 85 77 for song_id_key, ordered_feature_vals in sorted(csv_features_dict.items()): 78 print(str(song_id_key) + "\n" + str(ordered_feature_vals)) 79 80 81 groundtruth_dir = 'prepare/annotations/annotations\ averaged\ per\ song/dynamic\ \(per\ second\ annotations\)' 86 groundtruth_dir = 'prepare/annotations/annotations averaged per song/dynamic (per second annotations)' 82 87 arousal_csv_filename = groundtruth_dir + '/arousal.csv' 83 val ance_csv_filename = groundtruth_dir + '/valance.csv'88 valence_csv_filename = groundtruth_dir + '/valence.csv' 84 89 85 90 86 91 arousal_groundtruth_dict = csv_groundtruth_to_dict(arousal_csv_filename) 87 val ance_groundtruth_dict = csv_groundtruth_to_dict(valance_csv_filename)92 valence_groundtruth_dict = csv_groundtruth_to_dict(valence_csv_filename) 88 93 89 #print(f'Processed {line_count} lines.') 94 print("Arousal Ground-truth (sample of first 3 ids):") 95 i = 1 96 for song_id_key, ordered_feature_vals in sorted(arousal_groundtruth_dict.items()): 97 print(str(song_id_key) + "\n" + str(ordered_feature_vals)) 98 if i >= 3: 99 break 100 i = i + 1
Note:
See TracChangeset
for help on using the changeset viewer.