How can I separate Complicated CSV file

1 次查看(过去 30 天)
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

采纳的回答

Chris Perkins
Chris Perkins 2017-11-17
编辑:Chris Perkins 2017-11-17
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by