import data from a .txt file with multiple delimiters and headerlines
Show older comments
Hello dear Matlab Gurus,
I would like to know a way to import data from a .txt file. The file has 5 lines which I would like to ignore and the columns are separated by commas and > (larger than symbol). Here is an example of the .txt file:
>>128
10347
00>17:05:38,06/27/12,78.0,920
01>17:05:42,06/27/12,78.0,920
02>17:05:45,06/27/12,78.0,920
I would like the outcome to look something like this:
00 17:05:38 06/27/12 78.0 920 01 17:05:42 06/27/12 78.0 920 02 !7:05:45 06/27/12 78.0 920
Or even better, if I could ignore the first column and show the time and date columns as serial time and date. So have only 4 columns like this:
0.71224537 39625 78.00 920 ....
The last step could probably be done after the import.
So far I have been trying to use this code but without much luck :
fd = fopen('file.txt','rt');
data = textscan(fd, '%d%d%f%d', 'delimiter', ', >','headerlines',5);
fclose(fd);
I hope I described my problem good enough and someone will be able to help me. Any hint into the right direction is very appreciated...
Thank you very much...
Nils
Accepted Answer
More Answers (0)
Categories
Find more on Evaluation 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!