Problem reading lines from .dat file
显示 更早的评论
Hello,
I want to read a .dat file into matlab line by line, using a function like 'textscan' or 'sscanf'. Each line looks like the following:
3,424, 10:50:34.177, 0, 2,863333, 1,478, 54, 127,7047, 90,19555, 0, 0, 0,7567907, 3479,262, 16,07539, 0, 108, 228, 48, 1,046861, 1,067549, 0, 1,096976, 123, 88, 1613,094, 56449,5, 6, 0,5, 103,0865, 0
What is inconvenient is that the commas (',') are used both as delimiters and for the decimal places. Apparently this causes an error when reading the line, for instance when I'm using
textscan(tline,'%f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f','Delimiter',', ','EmptyValue',-Inf);
it seperates the "3,424" into "3" and "424". I tried using different options for Delimiter , as ', ' or ',\b' to make clear that the numbers are seperated by a Comma+Empty Space, but I couldn't find any way to tell Matlab that there are two types of commas and that it shoud seperate '3,424' from '10:50:34.177' but not '3' from '424'.
Can anyone please help me correctly reading these lines into Matlab?
Many thanks, Denis
采纳的回答
更多回答(1 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Standard File Formats 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!