How can I separate Complicated CSV file

조회 수: 1 (최근 30일)
Barry Smith
Barry Smith 2017년 11월 15일
편집: Chris Perkins 2017년 11월 17일
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