Create Sparse Matrix in Python
问题 Working with data and would like to create a sparse matrix to later be used for clustering purposes. fileHandle = open('data', 'r') for line in fileHandle: json_list = [] fields = line.split('\t') json_list.append(fields[0]) json_list.append(fields[1]) json_list.append(fields[3]) Right now the data looks like this: term, ids, quantity ['buick', '123,234', '500'] ['chevy', '345,456', '300'] ['suv','123', '100'] The output I would need would be like this: term, quantity, '123', '234', '345',