Read text file with multiple delimiters in a single row
Show older comments
Hi
I have some accelerometer data from an Arduino board (see attached test file showing 6 columns of data but with multiple delimiters on each row (commas and \t)). Each row of data (fron 2nd row onwards) features a high precision time stamp, type, arduino time, X, Y and Z components). I'm not sure how how to separate the data into individual columns using textscan.
2nd line of data:
1643148827196364700,0.92554\t0.34692\t0.15991 translates to: 16:43:14.882 (time stamp) 7196364700 (type and arduino time - honestly I'm not sure what the split is here) 0.92554 9 (X) 0.34692 (Y) 0.15991 (Z)
Can someone please help?
data_dir = '/MATLAB Drive/Arduino Accel';
test_id = 'Test';
path = fullfile(data_dir,strcat(test_id,'.txt'));
fid = fopen(path, 'rt');
tline = fgetl(fid);
headers = strsplit(tline, ',');
%% datacell = textscan(fid, ....???
% fclose(fid);
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

