Clear Filters
Clear Filters

can someone tell me how can i read this text file?

1 view (last 30 days)
hello i have text file . i am trying to read it read it but not getting the results.
endarcfmt = ['%s', repmat('%f64',1,4)]
fid = fopen('half.txt','r');
dc = textscan(fid, arcfmt, 'HeaderLines', 1, 'Delimiter', '\t', 'EmptyValue', uint8(0), 'CollectOutput', 1)
fclose(fid);
160a01184201c500 3.63392E+18 6.04919E+18 7.30445E+18
160a011842034200 3.63392E+18 6.04919E+18 7.30445E+18
160a01184204f700 3.63392E+18 6.04919E+18 7.30445E+18
160a01184209c800 7.17463E+18 7.63062E+16 4.97705E+18
160a0118421bcb00 3.63392E+18 6.04919E+18 7.30445E+18
160a0118421bcc00 3.63392E+18 6.04919E+18 7.30445E+18
160a011842376000 1.59888E+18 4.90256E+18 8.61872E+18
160a0118423b6400 8.67273E+18 6.735E+18 3.26382E+18
160a0118424ecd00 8.67273E+18 6.735E+18 3.26382E+18
160a0118424ece00 8.67273E+18 6.735E+18 3.26382E+18
160a0118424f3200 8.67273E+18 6.735E+18 3.26382E+18
160a0118424f4e00 8.67273E+18 6.735E+18 3.26382E+18
160a0118424f6a00 8.67273E+18 6.735E+18 3.26382E+18
160a0118424f7000 8.67273E+18 6.735E+18 3.26382E+18
160a0118424f7300 2.06908E+18 8.49562E+17 8.23739E+18
160a0118424f8d00 8.67273E+18 6.735E+18 3.26382E+18
160a0118424fb700 2.06908E+18 8.49562E+17 8.23739E+18
160a0118424fb800 2.06908E+18 8.49562E+17 8.23739E+18

Accepted Answer

Walter Roberson
Walter Roberson on 18 Oct 2016
It appears to be
dc = textscan(fid, arcfmt, 'HeaderLines', 1, 'Delimiter', '\t', 'MultipleDelimsAsOne', true, 'CollectOutput', 1);
This will only work if there are no missing column entries. If there are missing column entries then it gets complicated to try to figure out when the multiple tabs are there to make things pretty, and when there are there to indicate that the value is not present.
  11 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Data Type Conversion 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!