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 Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by