Skip to content

Instantly share code, notes, and snippets.

Created Jan 7, 2017
What would you like to do?
items = [];
for i in range(1,len(lines)):
line = lines[i].split(',');
itemFeatures = {"Class" : line[-1]};
for j in range(len(features)):
#Iterate through the features
f = features[j]; #Get the feature at index j
#The first item in the line is the class, skip it
v = float(line[j]); #Convert value to integer
itemFeatures[f] = v; #Add feature to dict
items.append(itemFeatures); #Append temp dict to items
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment