Reading numerical data from a .fcsv file with textscan

2 views (last 30 days)
Example data file:
## Markups fiducial file version = 4.4
## CoordinateSystem = 0
## columns = id,x,y,z,ow,ox,oy,oz,vis,sel,lock,label,desc,associatedNodeID
vtkMRMLMarkupsFiducialNode_0,-0.00025,40.5515,0.7,0,0,0,1,1,1,0,F-1,,vtkMRMLScalarVolumeNode2 vtkMRMLMarkupsFiducialNode_6,28.9653,8.27561,0.7,0,0,0,1,1,1,0,F-6,,vtkMRMLScalarVolumeNode2 vtkMRMLMarkupsFiducialNode_5,0,0,0,0,0,0,1,1,1,0,F-5,,vtkMRMLScalarVolumeNode6
Code:
fileID = fopen('F.fcsv');
C = textscan(fileID,'%*s %f %f %f %f %f %f %f %f %f %*s %*s %*s', 'Delimiter', '\n','headerLines', 14, 'CollectOutput', 1)
fclose(fileID);
%%
The output it returns is C= [0x9] double. How do I get the numerical data in matrix form? (first nine numbers in a 3 by 3 matrix?)

Answers (1)

Star Strider
Star Strider on 9 Apr 2015
I don’t have your file so I can’t experiment with it.
I would change your textscan call to:
C = textscan(fileID,'%*s %f %f %f %f %f %f %f %f %f %*s %*s %*s', 'Delimiter', ',','headerLines', 14, 'CollectOutput', 1);
You might also need to add: 'EndOfLine','\r\n' to the argument list, but first see if the changes here work.

Categories

Find more on Large Files and Big Data in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!