Professional Documents
Culture Documents
Join String
Join String
import numpy
label_map = [] # the map that holds the link between the label and the
one_hot_encoded label
file_info = [] # holds all your file locations and the label of the
file
#read all the lines. A line should look like this: mycatimage.png,1
with open('labels.txt') as f:
rows = [re.split(",", line.rstrip("\n")) for line in f]
# Write the found labels to the label file if you want for later use.
We will use the label_map variable for now
with open("mylabelfile.txt", 'w+') as lf:
for label in label_map:
lf.write(label['name'] + ',' + ','.join(str(x) for x in
label['value']) + "\n") # writes --> Christina,0,0,1,0\n