我正在处理MATLAB中的跟踪并使用在文本文件中提供检测响应的数据集。
我正在尝试读取此文件并将其保存在CSV文件中,然后处理CSV文件以进行处理。
文本文件信息不是逐行排序的,数据集中有两个文本文件。其中一个名称为“gt.txt”,另一个名为“det.txt”。
显示文本文件的示例(逗号分隔):
1,-1,198,203,62.22,141.19,42.848,-1,-1,-1
1,-1,140,272,36.769,83.436,41.154,-1,-1,-1
1,-1,396,178,104,236,35.498,-1,-1,-1
1,-1,160,252,47.893,108.68,34.648,-1,-1,-1
1,-1,54,264,74.286,168.57,23.007,-1,-1,-1
1,-1,166,201,52,118,15.845,-1,-1,-1
1,-1,277,188,86.667,196.67,15.655,-1,-1,-1
2,-1,198,203,62.22,141.19,55.025,-1,-1,-1
2,-1,134,196,74.286,168.57,45.498,-1,-1,-1
2,-1,412,178,104,236,38.049,-1,-1,-1
2,-1,48,174,112.01,254.17,34.822,-1,-1,-1
2,-1,275,222,62.22,141.19,29.457,-1,-1,-1
2,-1,157,184,74.286,168.57,0.086108,-1,-1,-1
3,-1,152,272,40,90.769,46.466,-1,-1,-1
3,-1,255,198,80,181.54,44.237,-1,-1,-1
3,-1,428,178,104,236,42.217,-1,-1,-1
3,-1,175,252,47.893,108.68,32.099,-1,-1,-1
3,-1,62,321,52,118,17.375,-1,-1,-1
3,-1,208,202,56.877,129.07,13.465,-1,-1,-1
3,-1,134,167,40,90.769,12.379,-1,-1,-1
3,-1,174,201,52,118,6.7745,-1,-1,-1
4,-1,250,188,86.667,196.67,51.231,-1,-1,-1
4,-1,146,196,74.286,168.57,48.567,-1,-1,-1
4,-1,428,178,104,236,40.005,-1,-1,-1
4,-1,53,156,125.53,284.85,27.227,-1,-1,-1
5,-1,157,196,74.286,168.57,45.902,-1,-1,-1
5,-1,486,297,52,118,45.846,-1,-1,-1
5,-1,263,274,47.893,108.68,42.095,-1,-1,-1
5,-1,214,253,40,90.769,25.063,-1,-1,-1
5,-1,146,167,40,90.769,17.37,-1,-1,-1
5,-1,94,249,52,118,16.452,-1,-1,-1
5,-1,70,321,52,118,14.368,-1,-1,-1
5,-1,454,219,74.286,168.57,13.63,-1,-1,-1
答案 0 :(得分:0)
所以问题是你的“csv-file”是逗号分隔的,但是新的行由空格定义?
fid=fopen('det.txt','rt');
str=fread(fid,inf,'uint8=>char')
result = cell2mat(textscan(str,'%f,%f,%f,%f,%f,%f,%f,%f,%f,%f '))
csvwrite('result.txt',result);