Reputation: 4656
In my text file I have several lines of input in the following format
Arun 3 4.0 Text
where Text can be a string of several words separated by spaces.
I want to read this into MATLAB such that I get a 4xn matrix, where Arun, 3, 4.0, Text should be the four fields for each entry in the Result Matrix.
I tried using fscanf
, but fscanf
assumes that the different terms are space separated.
So in the above example, if Text was say "Hello World", then fscanf
returns 5 items
[Arun, 3, 4.0, Hello, World]
but what I want is something like
[Arun, 3, 4.0, Hello World]
So, how do I achieve this in Hadoop?
Upvotes: 2
Views: 2789
Reputation: 1241
Try to use textscan function (http://www.mathworks.com/help/matlab/ref/textscan.html):
C = textscan(fileID, '%s %d %f %[^\n]')
Upvotes: 3