Datasets:
Tasks:
Feature Extraction
Modalities:
Image
Formats:
imagefolder
Languages:
English
Size:
1K - 10K
Tags:
code
License:
| t = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' | |
| import os | |
| dirs = r'E:\group_5\labels_g3_1' | |
| ndirs = r'E:\group_5\labels_3' | |
| for filenames in os.listdir(dirs): | |
| if filenames.endswith('.txt'): | |
| old_file = os.path.join(dirs, filenames) | |
| new_file = os.path.join(ndirs, filenames) | |
| with open(old_file, 'r') as f: | |
| lines = f.readlines() | |
| if len(lines) != 6: | |
| print(f"File {filenames} does not have exactly 6 lines.") | |
| continue | |
| idx = [t.index(c) for c in filenames.split('_')[0]] | |
| with open(new_file, 'w') as f: | |
| for i,line in enumerate(lines): | |
| line = line.split(' ') | |
| line[0] = str(idx[i]) | |
| f.write(' '.join(line)) |