I have hundreds of .csv-files, I attached one of them for example (Had to shorten it, beacuse it was bigger than 5 MB). Each of them has 10^6 Lines with data.
And I want to import those files automatically in my Matlab code. It is totally enough to import them one by one, but unfortunately I always had to preprocess this data manually with Text Editor. The problem is the text in the header of every .csv-file. I just want to import the numbers of the second, third and fourth column and not the text from the header. But even if I specify the columns, I cannot convert the recieved data store in numbers to run the calculations. This is my solution with the preprocessed data:
pre_data = datastore('Data.csv');
piece = zeros(1,3);
while hasdata(pre_data)
pie = read(pre_data);
pie = pie(:,1:3);
pie = table2array(pie);
piece = [piece; pie];
end
piece = piece(9:10^6+8,:);
With "piece", I can now easily run the calculations
To import the data without preprocessing, I tried "ds.SelectedVariableNames" and replacing "datastore" with "csvread". But nothing works.
Have anyone an advice, how to import such csv-files as an easily processable 1000000x3-double?
1 Comment
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/435908-how-can-i-import-only-the-numbers-from-an-csv-files-with-a-text-header#comment_650985
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/435908-how-can-i-import-only-the-numbers-from-an-csv-files-with-a-text-header#comment_650985
Sign in to comment.