用逗号读取大 .csv 文件 MATLAB

Reading big .csv file MATLAB with commas

我有一个很大的 csv 文件(650 万 x 25)并试图将其加载到 Matlab。我已经尝试了 xlsreadcsvread 但无法获得令人满意的结果。我读到我可以通过使用 textscan 来实现它。

我的数据是这样的:

date_time;writetime;F1;F2;F3;R1;h12;b12;h_main;
01.01.2016 0:00:01;504910801075;1;1;1;3,94;799;1515;3,877;
01.01.2016 0:00:02;504910802314;1;1;1;3,96;795;1516;3,857;

第一行是 header。其他行是数据。所有其他行的格式相同。

我的代码:

fileID = fopen('value1.csv','r');
formatSpec = '%s; \n';

formatSpec1 = '%s%f %f %f %f %f %f %f %f %f %f\n';
A1 = fscanf(fileID, formatSpec);

A2 = textscan(fileID, formatSpec1,'Delimiter',{';', ','});

我读了header到A1没关系:

A1 =
date_time;writetime;F1;F2;F3;R1;h12;b12;h_main;

并将数据也读取到 A2

A2 = 
    {1x1 cell}   [5.0491e+11]   [1]   [1]   [1]   [3]   [94]   [799]   [1515]   [3]   [877]

但是如何读取 3,94 值? 因为它可以只是 40,064 这一列中的值。

希望得到您的帮助!

我会将它们视为一个字符串。以下作品。

fileID = fopen('value1.csv','r');
formatSpec = '%s; \n';
A1 = fscanf(fileID, formatSpec);
formatSpec1 = '%s%f %f %f %f %s %f %f %s\n';
A2 = textscan(fileID, formatSpec1,'Delimiter',{';'});
A2{6} = str2double(strrep(A2{6},',','.'));
A2{end} = str2double(strrep(A2{end},',','.'));

{1x1 cell}    [5.0491e+11]    [1]    [1]    [1]    [3.94]    [799]    [1515]    [3.8770]