read csv file with a lot of columns.
Show older comments
Hello guys, i have the uploaded .csv file and i would like to only read the numbers that start with 0. how do i that? i tried 'readtable' and it reads but it puts everything in one cell and for textscan it has way too many columns.
I would appreciate some help thanks!
Answers (2)
A much better approach would use READTABLE to correctly import that numeric data (with decimal-commas in what is actually a semicolon-separated values file, not a CSV file). Do not import numeric data as text, as you are doing now. Fiddling around with text like that is fragile and inefficient.
T = readtable('rawdata.csv','FileType','text', 'Delimiter',';', 'DecimalSeparator',',',...
'ReadVariableNames',true, 'VariableNamingRule','preserve')
T.Timestamp % it even identifies the timestamp correctly.
1 Comment
Alex Perrakis
on 31 Mar 2022
try this:
A=readtable('rawdata.csv','ReadVariableName',false);
B=table2array(A(:,1));
C=split(B,';');
output=C(:,2:125);
6 Comments
Alex Perrakis
on 30 Mar 2022
B=table2array(A(:,1)); % converts the table, T, to a homogeneous array, B
C=split(B,';'); % split the string with delimiter semicolon.
output=C(:,2:125); % use linear indexing to find out the value starts with 0
Alex Perrakis
on 30 Mar 2022
Arif Hoq
on 30 Mar 2022
please attach your csv file
Alex Perrakis
on 30 Mar 2022
Arif Hoq
on 30 Mar 2022
try this:
A=readtable('rawdata2.csv','ReadVariableName',false);
B=table2array(A(:,1));
C=split(B,';');
output=C(:,2:126);
Categories
Find more on Text Files 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!