How can I separate Complicated CSV file

1 visualización (últimos 30 días)
Barry Smith
Barry Smith el 15 de Nov. de 2017
Editada: Chris Perkins el 17 de Nov. de 2017
How I would go about separating this csv file:
Header Header Header Header
1 row of data
Header Header Header
... Variable amount of data rows ...
Repeated x amount of times.
Many thanks

Respuesta aceptada

Chris Perkins
Chris Perkins el 17 de Nov. de 2017
Editada: Chris Perkins el 17 de Nov. de 2017
Hi Barry,
Since there is no marker present in the CSV file to say which rows are headers and which contain data, and since there are a variable number of rows with data, you will need to manually determine which rows contain headers by looking at the data once it has been imported to MATLAB using either the import tool or a specific function to read the CSV file.
Once you have determined which rows contain header values (say, row x1, x2, x3 ...) you can then extract rows 1-x1 and place those rows in their own matrix or table, then do the same for rows x1+1 to x2, and x2+1 to x3, and so on.
Alternatively, you could use the import tool multiple times and just select one section of rows at a time from the CSV file.
For more information about the import tool, see the following documentation link:
If it is possible for you to adjust how the CSV file is created so only the first row contains header information, that may be an easier workflow.

Más respuestas (0)

Categorías

Más información sobre Workspace Variables and MAT-Files en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by