reading csv file into matrices
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Pawan G
el 11 de Abr. de 2019
Comentada: Walter Roberson
el 15 de Abr. de 2019

I want to read a .csv file into matricies (n*8). The csv file is semicolon seperated and decimal is comma (German format). In the beginning,the csvfile has statements but i am only interested from a11 to end. Could anyone help me to read this file. thanks in advance.
0 comentarios
Respuesta aceptada
Walter Roberson
el 12 de Abr. de 2019
filename = '270219etc.CSV';
S = fileread(filename);
NLpos = find(S == sprintf('\n'));;
S(1:NLpos(10)) = []; %delete first 10 lines
S(S==',') = '.';
fmt = repmat('%f', 1, 8);
data = cell2mat( textscan(S, fmt, 'Delimiter', ';'));
2 comentarios
Walter Roberson
el 15 de Abr. de 2019
NLpos is the position of all of the newlines in the input file. Indexing at 10 gives you the position of the end of the 10th line of input. You then remove everything from the beginning to there which removes the first 10 lines from the string.
Más respuestas (0)
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!