I have a file in the following format in matlab:
user_id_a: (item_1,rating),(item_2,rating),...(item_n,rating)
user_id_b: (item_25,rating),(item_50,rating),...(item_x,rating)
....
....
therefore, each line has values ββseparated by a colon, where the value to the left of the colon is a number representing user_id, and the values ββto the right are tuples item_ids (also numbers) and rating (numbers do not float).
I would like to read this data in an array of Matlab cells or better, but ultimately convert it to a sparse matrix, where user_id represents the index of the row and item_id represents the index of the column and stores the corresponding rating in that index of the array. (This will work because I know a priori the number of users and elements in my universe, so identifiers cannot be larger than this).
Any help would be appreciated.
I have so far tried the textscan function as follows:
c = textscan(f,'%d %s','delimiter',':') %this creates two cells one with all the user_ids
%and another with all the remaining string values.
, - str2mat(c{2}), , '(' ')' . , .
Matlab .