Create a matrix from a csv

Hello, I have a csv file with a structure like this (or just take a look at the csv):
  1. name11,name21,name31
  2. number,number,number
  3. number,number,number
  4. ...
  5. name21,name22,name23
  6. number,number,number
  7. number,number,number
  8. ...
  9. name31,name32,name33
  10. number,number,number
  11. ...L ist the length of the space between two names, N is the number of matrixes.I want to save every number between two names as a separate matrix, the best would be a Lx3xN.How can I do that?

4 comentarios

Guillaume
Guillaume el 6 de Nov. de 2018
Editada: Guillaume el 6 de Nov. de 2018
Do you know L beforehand, or is it to be determined from the file?
And can you supply a test file as it would avoid us having to make one up?
Lorant
Lorant el 6 de Nov. de 2018
Editada: Lorant el 6 de Nov. de 2018
L should be determined from the file. I als added the testfile to the original question.
Jan
Jan el 6 de Nov. de 2018
There are some blank lines in addition.
How do you want to treat the date?
5 Nov 2018 11:00:00.000,6110.403876,-1714.451633,2349.558833
This does not match the pattern "number,number,number" exactly.
Lorant
Lorant el 6 de Nov. de 2018
Yeah, that's true, I don't need the date, just the last three numbers.

Iniciar sesión para comentar.

Respuestas (1)

madhan ravi
madhan ravi el 6 de Nov. de 2018
Editada: madhan ravi el 6 de Nov. de 2018

0 votos

Try
readtable()
T=readtable('Testfile_1.csv');
T(:,end-2:end) %reads last three columns

Categorías

Más información sobre Holidays / Seasons en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 6 de Nov. de 2018

Editada:

el 6 de Nov. de 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by